class Container implements ContainerInterface, ArrayAccess

Class Container

Methods

mixed
get(string $id)

Get an entry from the container.

bool
has(string $id)

See if the container has an entry for the ID.

mixed
set($id, $value)

Add a new entry to the container.

offsetExists(string $offset)

Check to see if an offset exists.

offsetGet(mixed $offset)

Get an Offset.

offsetSet(string $offset, mixed $value)

Set an Offset.

offsetUnset(string $offset)

Unset an Offset.

Details

at line 31
mixed get(string $id)

Get an entry from the container.

This method will attempt to get an entry from the container. The ID must be a string or it will throw a ContainerException. It will then check if the container has an entry for that ID, if it does not then it will throw a NotFoundException.

Parameters

string $id

Return Value

mixed

Exceptions

ContainerException
NotFoundException

at line 58
bool has(string $id)

See if the container has an entry for the ID.

Has will check the container to see if there is an entry for the ID. The ID must be a string or it will throw a ContainerException. Then it will check to see if the container has an entry, it will return true if it has one and false if it doesn't.

Parameters

string $id

Return Value

bool

Exceptions

ContainerException

at line 82
mixed set($id, $value)

Add a new entry to the container.

Set will add a new entry to the container. The ID must be a string or it will throw a ContainerException. The value can be anything, as long as it isn't itself. Don't try and add the container to the container. It returns the value that you set, if you want to confirm that.

Parameters

$id
$value

Return Value

mixed

Exceptions

ContainerException

at line 96
offsetExists(string $offset)

Check to see if an offset exists.

Essentially returns isset on a key in the private property $container.

Parameters

string $offset

at line 108
offsetGet(mixed $offset)

Get an Offset.

Essentially the same as accessing an offset of an array.

Parameters

mixed $offset

at line 121
offsetSet(string $offset, mixed $value)

Set an Offset.

Essentially the same as setting a key/value of an array.

Parameters

string $offset
mixed $value

at line 133
offsetUnset(string $offset)

Unset an Offset.

Essentially unsetting a key/value of an array.

Parameters

string $offset