Documentation

ContainerContract

Table of Contents

closureFactory()  : object
Creates a class instance using closure.
exec()  : object
Execute a callable and inject its dependencies.
factory()  : object
Creates a class instance.
get()  : object
Returns a class instance.
has()  : bool
Checks if a class is registered in the container.
isSingleton()  : bool
Returns TRUE if a class has been registered as a singleton and FALSE if not.
reflectionFactory()  : object
Creates a class instance using reflection.
register()  : void
Register a type hint.
registerContextualDependency()  : void
Registers a contextual dependency.
registerInstance()  : void
Register a singleton instance.
registerSingleton()  : mixed
Register a type hint and return the same instance every time.

Methods

closureFactory()

Creates a class instance using closure.

public closureFactory(closure $factory, array<string|int, mixed> $parameters) : object
Parameters
$factory : closure

Closuare.

$parameters : array<string|int, mixed>

Constructor parameters.

Tags
since
1.0.0
Return values
object

exec()

Execute a callable and inject its dependencies.

public exec(callable $callable[, array<string|int, mixed> $parameters = [] ]) : object
Parameters
$callable : callable

Callable.

$parameters : array<string|int, mixed> = []

Parameters.

Tags
since
1.0.0
Return values
object

factory()

Creates a class instance.

public factory(string|Closure $class[, array<string|int, mixed> $parameters = [] ]) : object
Parameters
$class : string|Closure

Class name or closure.

$parameters : array<string|int, mixed> = []

Constructor parameters.

Tags
since
1.0.0
Return values
object

get()

Returns a class instance.

public get(string $class[, array<string|int, mixed> $parameters = [] ]) : object
Parameters
$class : string

Class name.

$parameters : array<string|int, mixed> = []

Constructor parameters.

Tags
since
1.0.0
Return values
object

has()

Checks if a class is registered in the container.

public has(string $class) : bool
Parameters
$class : string

Class name.

Tags
since
1.0.0
Return values
bool

isSingleton()

Returns TRUE if a class has been registered as a singleton and FALSE if not.

public isSingleton(string $class) : bool
Parameters
$class : string

Class name.

Tags
since
1.0.0
Return values
bool

reflectionFactory()

Creates a class instance using reflection.

public reflectionFactory(mixed $class[, array<string|int, mixed> $parameters = [] ]) : object
Parameters
$class : mixed

Class name.

$parameters : array<string|int, mixed> = []

Constructor parameters.

Tags
since
1.0.0
Return values
object

register()

Register a type hint.

public register(string|array<string|int, mixed> $hint, string|Closure $class[, bool $singleton = false ]) : void
Parameters
$hint : string|array<string|int, mixed>

Type hint or array contaning both type hint and alias.

$class : string|Closure

Class name or closure.

$singleton : bool = false

Should we return the same instance every time?

Tags
since
1.0.0
Return values
void

registerContextualDependency()

Registers a contextual dependency.

public registerContextualDependency(string $class, string $interface, string $implementation) : void
Parameters
$class : string

Class.

$interface : string

Interface.

$implementation : string

Implementation.

Tags
since
1.0.0
Return values
void

registerInstance()

Register a singleton instance.

public registerInstance(string|array<string|int, mixed> $hint, object $instance) : void
Parameters
$hint : string|array<string|int, mixed>

Type hint or array contaning both type hint and alias.

$instance : object

Class instance.

Tags
since
1.0.0
Return values
void

registerSingleton()

Register a type hint and return the same instance every time.

public registerSingleton(string|array<string|int, mixed> $hint, string|Closure $class) : mixed
Parameters
$hint : string|array<string|int, mixed>

Type hint or array contaning both type hint and alias.

$class : string|Closure

Class name or closure.

Tags
since
1.0.0
Return values
mixed

Search results