MySportsFeeds / mysportsfeeds-php

PHP wrapper for the MySportsFeeds Sports Data API

Home Page:https://www.mysportsfeeds.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Base class BaseApi.php properties like $this->baseUrl have no value in subclasses

ok6245 opened this issue · comments

When I make some local fixes so that I can get to the point where I can instantiate a MySportsFeed object for version 2.0, I get an object in which the base properties have not been filled in.

My code

   $msf = new MySportsFeeds("2.0", true, null, '');
   echo print_r($msf, true);

gives me this:

MySportsFeeds\MySportsFeeds Object
(
    [buildVersion] => 2.0.0
    [version:MySportsFeeds\MySportsFeeds:private] => 2.0
    [verbose:MySportsFeeds\MySportsFeeds:private] => 1
    [storeType:MySportsFeeds\MySportsFeeds:private] => 
    [storeLocation:MySportsFeeds\MySportsFeeds:private] => 
    [apiInstance:MySportsFeeds\MySportsFeeds:private] => MySportsFeeds\API_v2_0 Object
        (
            [auth:protected] => 
            [baseUrl:protected] => 
            [verbose:protected] => 
            [storeType:protected] => 
            [storeLocation:protected] => 
            [storeOutput:protected] => 
            [version:protected] => 
            [validFeeds:protected] => Array
                (
                    [0] => seasonal_games
                    [1] => daily_games
                    ...
                    [21] => players
                    [22] => seasonal_standings
                )
        )
)

Note in the "apiInstance" object, that the properties (like auth, baseUrl, ...) which are only ever initialized in BaseApi, are all blank (uninitialized?).

When I try to getData() using the MySportsFeed object, the CURL url has no "baseUrl" portion. It is missing the starting "https://api.mysportsfeeds.com/..." portion.

I was able to correct this by making sure that every subclass of BaseApi had an explicit constructor, and all of those subclass constructors calls the parent constructor first thing:
parent::__construct($version, $verbose, $storeType, $storeLocation)
I don't know if my solution was the best or proper way to fix this.

This issue can be closed, it was handled in pull request #14 Won't-run-due-to-PHP-errors