PHP Class Inpsyde\MultilingualPress\Service\AddOnlyContainer

Since: 3.0.0
Inheritance: implements Inpsyde\MultilingualPress\Service\Container
Show file Open project: inpsyde/multilingual-press Class Usage Examples

Public Methods

Method Description
__construct ( array $values = [] ) Constructor. Sets up the properties.
bootstrap ( ) : void Bootstraps (and locks) the container.
extend ( string $name, callable $new_factory ) : static Replaces the factory callback with the given name with the given factory callback.
lock ( ) : void Locks the container.
offsetExists ( string $name ) : boolean Checks if a value or factory callback with the given name exists.
offsetGet ( string $name ) : mixed Returns the value or factory callback with the given name.
offsetSet ( string $name, mixed $value ) : void Stores the given value or factory callback with the given name.
offsetUnset ( string $name ) : void Removes the value or factory callback with the given name.
share ( string $name, mixed $value ) : static Stores the given value or factory callback with the given name, and defines it to be accessible even after the container has been bootstrapped.

Method Details

__construct() public method

Constructor. Sets up the properties.
Since: 3.0.0
public __construct ( array $values = [] )
$values array Initial values or factory callbacks to be stored.

bootstrap() public method

Only shared values and factory callbacks are accessible from now on.
Since: 3.0.0
public bootstrap ( ) : void
return void

extend() public method

The new factory callback will receive as first argument the object created by the current factory, and as second argument the container.
Since: 3.0.0
public extend ( string $name, callable $new_factory ) : static
$name string The name of an existing factory callback.
$new_factory callable The new factory callback.
return static Container instance.

lock() public method

A locked container cannot be manipulated anymore. All stored values and factory callbacks are still accessible.
Since: 3.0.0
public lock ( ) : void
return void

offsetExists() public method

Checks if a value or factory callback with the given name exists.
Since: 3.0.0
public offsetExists ( string $name ) : boolean
$name string The name of a value or factory callback.
return boolean Whether or not a value or factory callback with the given name exists.

offsetGet() public method

Returns the value or factory callback with the given name.
Since: 3.0.0
public offsetGet ( string $name ) : mixed
$name string The name of a value or factory callback.
return mixed The value or factory callback with the given name.

offsetSet() public method

Scalar values will get shared automatically.
Since: 3.0.0
public offsetSet ( string $name, mixed $value ) : void
$name string The name of a value or factory callback.
$value mixed The value or factory callback.
return void

offsetUnset() public method

Removing values or factory callbacks is not allowed.
Since: 3.0.0
public offsetUnset ( string $name ) : void
$name string The name of a value or factory callback.
return void

share() public method

Stores the given value or factory callback with the given name, and defines it to be accessible even after the container has been bootstrapped.
Since: 3.0.0
public share ( string $name, mixed $value ) : static
$name string The name of a value or factory callback.
$value mixed The value or factory callback.
return static Container instance.