Closed bogdanfinn closed 7 years ago
@bogdanfinn Thank's
Looks good from what I see.
You might rename that the class to ApiMediaObject
. You already of the MEDIA_TYPE_X constants. It is either Tv or Movie.
@webstractions Yeah, according to the naming i was not sure. I thought about creating two classes, a ApiBaseObject and a ApiMediaObject extending the ApiBaseObject, cause Movie and TVShow have a lot of similar methods, but Episode, Season, Person, etc. have also a few of the "Basemethods" every API Object should have. Then Movie and TVShow could extends the ApiMediaObject and Season, Episode and so on could extend die ApiBaseObject...
Thank you for you feedback!
@bogdanfinn Yep, having the ApiBaseObject is a good call. It would be a small class, but you can hook other things into it like loggers, json methods, etc that the others can inherit.
These are best left as abstract classes. Put them in their own folder like Abstract\MediaObject.php, Abstract\CreditsObject.php, Abstract\PersonObject.php, yada, yada. There are objects all over the place if you dig into it deep enough. Not sure how far you want to take that. Some are used in several places (like Person) and make sense to use.
@webstractions Thanks for the feedback. I'm going to refactor the code a litte bit more and make antother PR with your improvements.
Another Question:
What is your opinion in refactor all "Getter Methods" to never access the $_data property directly. Instead of it the getter should use the public function get($key);
method, because this method has additional checks to avoid "Undefined index"-errors.
For example:
I would change the method:
public function getOverview() { return $this->_data['overview']; }
to
public function getOverview() { return $this->get('overview'); }
And the get()-Method is placed in the ApiBaseObject ;-)
Second Question: What is your opinion about using namespaces and an autoloader according to PSR-4 ?
For Issue #48