This is the definition of a Dependency Container, also known as Inversion of Control Container, Service Container.
It comes with three groups of methods:
- Allows for singleton registration
/**
* @param string $dependency
* @param Closure $abstraction
*
* @return Container
*/
public function singleton(string $dependency, Closure $abstraction) : Container;
- Allows for a non singleton registration
/**
* @param string $dependency
* @param Closure $abstraction
*
* @return Container
*/
public function register(string $dependency, Closure $abstraction) : Container;
Each registered dependency can be retrieved with the resolve
method.
/**
* @param string $dependency
*
* @return mixed
* @throws UnresolvableDependencyException
*/
public function resolve(string $dependency);
/**
* @param object $object
* @param string $method
*
* @return mixed
* @throws UnresolvableDependencyException
*/
public function call(object $object, string $method);