Container

Implements \Kocuj\Di\Container\ContainerInterface

Dependency injection container for services

package

Kocuj\Di\Container

Methods

Call service by method get*(), where "*" is service identifier written in camel case

__call(string $method, array $arguments) : object
Throws
\Kocuj\Di\Container\Exception
\Kocuj\Di\Container\NotFoundException

Arguments

$method

string

Method to call

$arguments

array

Arguments for called method

Response

object

Service object

Cloning container

__clone() : void
Throws
\Kocuj\Di\Container\Exception

Constructor

__construct(\Kocuj\Di\ServiceIdDecorator\ServiceIdDecoratorInterface $serviceIdDecorator, \Kocuj\Di\Service\ServiceFactoryInterface $serviceFactory) 

Arguments

$serviceIdDecorator

\Kocuj\Di\ServiceIdDecorator\ServiceIdDecoratorInterface

Service identifier decorator

$serviceFactory

\Kocuj\Di\Service\ServiceFactoryInterface

Service factory

Add standard or shared service

add(\Kocuj\Di\Service\ServiceType $serviceType, string $id, string $source, array $arguments = array()) : \Kocuj\Di\Container\ContainerInterface
see \Kocuj\Di\Container\ContainerInterface::add()
Throws
\Kocuj\Di\Container\Exception

Arguments

$serviceType

\Kocuj\Di\Service\ServiceType

Service type

$id

string

Service identifier

$source

string

Service to create

$arguments

array

Service arguments to inject into constructor

Response

\Kocuj\Di\Container\ContainerInterface

This object

Add shared service

addShared(string $id, string $source, array $arguments = array()) : \Kocuj\Di\Container\ContainerInterface
see \Kocuj\Di\Container\ContainerInterface::addShared()
codeCoverageIgnore
Throws
\Kocuj\Di\Container\Exception

Arguments

$id

string

Service identifier

$source

string

Service to create

$arguments

array

Service arguments to inject into constructor

Response

\Kocuj\Di\Container\ContainerInterface

This object

Add standard service

addStandard(string $id, string $source, array $arguments = array()) : \Kocuj\Di\Container\ContainerInterface
see \Kocuj\Di\Container\ContainerInterface::addStandard()
codeCoverageIgnore
Throws
\Kocuj\Di\Container\Exception

Arguments

$id

string

Service identifier

$source

string

Service to create

$arguments

array

Service arguments to inject into constructor

Response

\Kocuj\Di\Container\ContainerInterface

This object

Check service type

checkType(string $id, \Kocuj\Di\Service\ServiceType $serviceType) : boolean
see \Kocuj\Di\Container\ContainerInterface::checkType()
Throws
\Kocuj\Di\Container\NotFoundException

Arguments

$id

string

Service identifier

$serviceType

\Kocuj\Di\Service\ServiceType

Service type

Response

boolean

This service has selected type (true) or not (false)

Get service

get(string $id) : object
see \Psr\Container\ContainerInterface::get()
Throws
\Kocuj\Di\Container\NotFoundException

Arguments

$id

string

Service identifier

Response

object

Service object

Get service definition

getServiceDefinition(string $id) : array
Throws
\Kocuj\Di\Container\NotFoundException

Arguments

$id

string

Service identifier

Response

array

Service definition

Get service type - for compatibility with 1.2.0

getType(string $id) : \Kocuj\Di\Service\ServiceType
deprecated
see \Kocuj\Di\Container\Container::checkType()
codeCoverageIgnore
Throws
\Kocuj\Di\Container\NotFoundException

Arguments

$id

string

Service identifier

Response

\Kocuj\Di\Service\ServiceType

Service type

Check if service exists

has(string $id) : boolean
see \Psr\Container\ContainerInterface::has()

Arguments

$id

string

Service

Response

boolean

Service exists (true) or not (false)

Properties

Service identifier decorator

serviceIdDecorator : \Kocuj\Di\ServiceIdDecorator\ServiceIdDecoratorInterface

Service factory

serviceFactory : \Kocuj\Di\Service\ServiceFactoryInterface

Definitions

definitions : array
var

Type(s)

array