PHP Class FOF30\Pimple\Container

Author: Fabien Potencier
Inheritance: implements ArrayAccess
Datei anzeigen Open project: akeeba/fof

Public Methods

Method Description
__construct ( array $values = [] ) Instantiate the container.
extend ( string $id, callable $callable ) : callable Extends an object definition.
factory ( callable $callable ) : callable Marks a callable as being a factory service.
keys ( ) : array Returns all defined value names.
offsetExists ( string $id ) : boolean Checks if a parameter or an object is set.
offsetGet ( string $id ) : mixed Gets a parameter or an object.
offsetSet ( string $id, mixed $value ) Sets a parameter or an object.
offsetUnset ( string $id ) Unsets a parameter or an object.
protect ( callable $callable ) : callable Protects a callable from being interpreted as a service.
raw ( string $id ) : mixed Gets a parameter or the closure defining an object.
register ( FOF30\Pimple\ServiceProviderInterface $provider, array $values = [] ) : static Registers a service provider.

Method Details

__construct() public method

Objects and parameters can be passed as argument to the constructor.
public __construct ( array $values = [] )
$values array The parameters or objects.

extend() public method

Useful when you want to extend an existing object definition, without necessarily loading that object.
public extend ( string $id, callable $callable ) : callable
$id string The unique identifier for the object
$callable callable A service definition to extend the original
return callable The wrapped callable

factory() public method

Marks a callable as being a factory service.
public factory ( callable $callable ) : callable
$callable callable A service definition to be used as a factory
return callable The passed callable

keys() public method

Returns all defined value names.
public keys ( ) : array
return array An array of value names

offsetExists() public method

Checks if a parameter or an object is set.
public offsetExists ( string $id ) : boolean
$id string The unique identifier for the parameter or object
return boolean

offsetGet() public method

Gets a parameter or an object.
public offsetGet ( string $id ) : mixed
$id string The unique identifier for the parameter or object
return mixed The value of the parameter or an object

offsetSet() public method

Objects must be defined as Closures. Allowing any PHP callable leads to difficult to debug problems as function names (strings) are callable (creating a function with the same name as an existing parameter would break your container).
public offsetSet ( string $id, mixed $value )
$id string The unique identifier for the parameter or object
$value mixed The value of the parameter or a closure to define an object

offsetUnset() public method

Unsets a parameter or an object.
public offsetUnset ( string $id )
$id string The unique identifier for the parameter or object

protect() public method

This is useful when you want to store a callable as a parameter.
public protect ( callable $callable ) : callable
$callable callable A callable to protect from being evaluated
return callable The passed callable

raw() public method

Gets a parameter or the closure defining an object.
public raw ( string $id ) : mixed
$id string The unique identifier for the parameter or object
return mixed The value of the parameter or the closure defining an object

register() public method

Registers a service provider.
public register ( FOF30\Pimple\ServiceProviderInterface $provider, array $values = [] ) : static
$provider FOF30\Pimple\ServiceProviderInterface A ServiceProviderInterface instance
$values array An array of values that customizes the provider
return static