\PimpleContainer

Container main class.

Summary

Methods
Properties
Constants
__construct()
offsetSet()
offsetGet()
offsetExists()
offsetUnset()
factory()
protect()
raw()
extend()
keys()
register()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$values
$factories
$protected
$frozen
$raw
$keys
N/A

Properties

$values

$values : 

Type

$factories

$factories : 

Type

$protected

$protected : 

Type

$frozen

$frozen : 

Type

$raw

$raw : 

Type

$keys

$keys : 

Type

Methods

__construct()

__construct(array  $values = array()) 

Instantiates the container.

Objects and parameters can be passed as argument to the constructor.

Parameters

array $values

The parameters or objects

offsetSet()

offsetSet(string  $id, mixed  $value) 

Sets a parameter or an object.

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).

Parameters

string $id

The unique identifier for the parameter or object

mixed $value

The value of the parameter or a closure to define an object

Throws

\Pimple\Exception\FrozenServiceException

Prevent override of a frozen service

offsetGet()

offsetGet(string  $id) : mixed

Gets a parameter or an object.

Parameters

string $id

The unique identifier for the parameter or object

Throws

\Pimple\Exception\UnknownIdentifierException

If the identifier is not defined

Returns

mixed —

The value of the parameter or an object

offsetExists()

offsetExists(string  $id) : boolean

Checks if a parameter or an object is set.

Parameters

string $id

The unique identifier for the parameter or object

Returns

boolean

offsetUnset()

offsetUnset(string  $id) 

Unsets a parameter or an object.

Parameters

string $id

The unique identifier for the parameter or object

factory()

factory(callable  $callable) : callable

Marks a callable as being a factory service.

Parameters

callable $callable

A service definition to be used as a factory

Throws

\Pimple\Exception\ExpectedInvokableException

Service definition has to be a closure or an invokable object

Returns

callable —

The passed callable

protect()

protect(callable  $callable) : callable

Protects a callable from being interpreted as a service.

This is useful when you want to store a callable as a parameter.

Parameters

callable $callable

A callable to protect from being evaluated

Throws

\Pimple\Exception\ExpectedInvokableException

Service definition has to be a closure or an invokable object

Returns

callable —

The passed callable

raw()

raw(string  $id) : mixed

Gets a parameter or the closure defining an object.

Parameters

string $id

The unique identifier for the parameter or object

Throws

\Pimple\Exception\UnknownIdentifierException

If the identifier is not defined

Returns

mixed —

The value of the parameter or the closure defining an object

extend()

extend(string  $id, callable  $callable) : callable

Extends an object definition.

Useful when you want to extend an existing object definition, without necessarily loading that object.

Parameters

string $id

The unique identifier for the object

callable $callable

A service definition to extend the original

Throws

\Pimple\Exception\UnknownIdentifierException

If the identifier is not defined

\Pimple\Exception\FrozenServiceException

If the service is frozen

\Pimple\Exception\InvalidServiceIdentifierException

If the identifier belongs to a parameter

\Pimple\Exception\ExpectedInvokableException

If the extension callable is not a closure or an invokable object

Returns

callable —

The wrapped callable

keys()

keys() : array

Returns all defined value names.

Returns

array —

An array of value names

register()

register(\Pimple\ServiceProviderInterface  $provider, array  $values = array()) : static

Registers a service provider.

Parameters

\Pimple\ServiceProviderInterface $provider

A ServiceProviderInterface instance

array $values

An array of values that customizes the provider

Returns

static