$value)
{
$container->register($key, $value['resolver'], (isset($value['singleton'])) ? $value['singleton'] : false);
}
}
/**
* Get a container instance.
*
* If no container name is specified, the default container will be returned.
*
*
* // Get the default container instance
* $container = IoC::container();
*
* // Get a specific container instance
* $container = IoC::container('models');
*
*
* @param string $container
* @return Container
*/
public static function container($container = 'default')
{
if ( ! array_key_exists($container, static::$containers))
{
static::$containers[$container] = new Container;
}
return static::$containers[$container];
}
/**
* Magic Method for passing methods to the default container.
*
*
* // Resolve an object from the default container
* $user = IoC::resolve('user');
*
* // Equivalent method of resolving using the container method
* $user = IoC::container()->resolve('user');
*
*/
public static function __callStatic($method, $parameters)
{
return call_user_func_array(array(static::container(), $method), $parameters);
}
}