class Container implements ContainerInterface, ArikaimContainerInterface, ArrayAccess

Dependency injection container.

Methods

__construct(array $services = null)

Container constructor

ContainerInterface
clone(array $items)

Clone container

mixed|null
getItem(string $id, mixed|null $default = null)

Get container service

mixed
get(string $id)

Get service from container

mixed|null
call(string $id, string $method, array $params = [])

Call service method

bool
has(string $id)

Check if service exists in container PSR-11 ContainerInterface

void
add(string $id, mixed $service, boolean $replace = false)

Add service to container

void
replace(string $id, mixed $service)

Replace service in container

void
remove(string $id)

Remove service from container

array
getServicesList()

Get array with all service id in container

bool
offsetExists(string $id)

ArrayAccess interface function

mixed
offsetGet(string $id)

ArrayAccess interface function

void
offsetSet(string $id, mixed $service)

ArrayAccess interface function

void
offsetUnset(string $id)

ArrayAccess interface function

Details

at line 36
__construct(array $services = null)

Container constructor

Parameters

array $services Container services

at line 47
ContainerInterface clone(array $items)

Clone container

Parameters

array $items

Return Value

ContainerInterface

at line 61
mixed|null getItem(string $id, mixed|null $default = null)

Get container service

Parameters

string $id Service id
mixed|null $default Default value

Return Value

mixed|null Service or null if not exist

at line 73
mixed get(string $id)

Get service from container

Parameters

string $id Srvice id

Return Value

mixed Service or null if not exist

Exceptions

ServiceNotFoundException;

at line 95
mixed|null call(string $id, string $method, array $params = [])

Call service method

Parameters

string $id
string $method
array $params

Return Value

mixed|null

at line 114
bool has(string $id)

Check if service exists in container PSR-11 ContainerInterface

Parameters

string $id Service id

Return Value

bool

at line 128
void add(string $id, mixed $service, boolean $replace = false)

Add service to container

Parameters

string $id Service id
mixed $service Service value
boolean $replace Replace service if exists

Return Value

void

Exceptions

ServiceExistsException If replace is false and service exists in container

at line 143
void replace(string $id, mixed $service)

Replace service in container

Parameters

string $id Sservice id
mixed $service Service value

Return Value

void

at line 154
void remove(string $id)

Remove service from container

Parameters

string $id Service id

Return Value

void

at line 166
array getServicesList()

Get array with all service id in container

Return Value

array

at line 177
bool offsetExists(string $id)

ArrayAccess interface function

Parameters

string $id Service id

Return Value

bool

at line 188
mixed offsetGet(string $id)

ArrayAccess interface function

Parameters

string $id Service id

Return Value

mixed

at line 200
void offsetSet(string $id, mixed $service)

ArrayAccess interface function

Parameters

string $id Service id
mixed $service Service value

Return Value

void

at line 211
void offsetUnset(string $id)

ArrayAccess interface function

Parameters

string $id Service id

Return Value

void