I don't mean this personally, but the class above will eat the server resources like a hog.
It is a class of too many methods. One probable solution I can think of is to break this class into multiple classes. There is a design pattern called Abstract Factory/Factory Method patterns which I think can work greatly on this type of application. Most importantly, if you are aiming for cache system.
The implementation of Abstract Factory/Factory Method patterns is kinda like this. ( Mr. LDA above thought me how to this, so any corrections are greatly appreciated). It appears to me that the class above is responsible for providing video contents coming from the external sites.
We can make a video factory class like this
class VideoFactory
{
private $ytube_content;
private $imgur_content;
private $dmotion_content;
private $flickr_content;
public function __construct(YouTube $ytube_content, Imgur $imgur_content, DailyMotion $dmotion_content, Flickr $flickr_content)
{
$this->ytube_content = $ytube_content;
$this->imgur_content = $imgur_content;
$this->dmotion_content = $dmotion_content;
$this->flickr_content = $flickr_content;
}
/*
* get the youtube data
*/
public function get_youtube()
{
return clone $this->ytube_content;
}
/*
* get imgur data
*/
public function get_imgur()
{
return clone $this->imgur_content;
}
/*
* get dailymotion data
*/
public function get_dailymotion()
{
return clone $this->dmotion_content;
}
/*
* get flickr data
*/
public function get_flickr()
{
return clone $this->flickr_content;
}
}
the video classes as broken down
class YouTube
{
public function __construct()
{
}
public function set_video()
{
//return all youtube video data
}
public function make_cache()
{
//you can make a …