Skip to content

Instantly share code, notes, and snippets.

@bakura10
Created September 1, 2013 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakura10/6406960 to your computer and use it in GitHub Desktop.
Save bakura10/6406960 to your computer and use it in GitHub Desktop.
class ServiceManager
{
protected $cache = array();
protected $factories = array();
public function create($name)
{
if (isset($this->factories[$name]) && !isset($this->cache[$name])) {
$this->cache[$name] = $this->factories[$name]->createService($this);
}
return $this->cache[$name];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment