PHP Class Essence\Di\Container

Inspired by Pimple (https://github.com/fabpot/Pimple). Pimple wasn't used because of the way composer works. If someone were working on a project using Pimple in a different version than Essence's, the installation would fail.
Show file Open project: benjamminf/craft-embedded-assets Class Usage Examples

Protected Properties

Property Type Description
$_properties array Container properties.

Public Methods

Method Description
configure ( array $properties ) Merges the given properties with the current ones.
get ( string $property, mixed $default = null ) : mixed Returns the value of the given property.
set ( string $property, mixed $value ) Sets the value of the given property.
unique ( Closure $closure ) : Closure Returns a wrapper that memoizes the result of the given closure.

Method Details

configure() public method

Merges the given properties with the current ones.
public configure ( array $properties )
$properties array Properties to merge.

get() public method

Returns the value of the given property.
public get ( string $property, mixed $default = null ) : mixed
$property string Property name.
$default mixed Default value to be returned in case the property doesn't exists.
return mixed The property value, or the result of the closure execution if property is a closure, or $default.

set() public method

Sets the value of the given property.
public set ( string $property, mixed $value )
$property string Property name.
$value mixed New value.

unique() public static method

Returns a wrapper that memoizes the result of the given closure.
public static unique ( Closure $closure ) : Closure
$closure Closure Closure to wrap.
return Closure Wrapper.

Property Details

$_properties protected property

Container properties.
protected array $_properties
return array