ContainerAdapter
in package
implements
IContainer
Adapter to make PSR-11 container compatible with Neuron's IContainer interface
Table of Contents
Interfaces
- IContainer
- PSR-11 compatible dependency injection container interface
Properties
- $container : ContainerInterface
Methods
- __construct() : mixed
- bind() : void
- Bind an abstract type to a concrete implementation
- get() : mixed
- Finds an entry of the container by its identifier and returns it.
- has() : bool
- Returns true if the container can return an entry for the given identifier.
- instance() : void
- Register an existing instance as a singleton
- make() : object
- Resolve and instantiate a class with automatic dependency injection
- singleton() : void
- Register a singleton (shared instance) in the container
Properties
$container
private
ContainerInterface
$container
Methods
__construct()
public
__construct(ContainerInterface $container) : mixed
Parameters
- $container : ContainerInterface
bind()
Bind an abstract type to a concrete implementation
public
bind(string $abstract, string $concrete) : void
Parameters
- $abstract : string
-
Interface or abstract class name
- $concrete : string
-
Concrete class name
get()
Finds an entry of the container by its identifier and returns it.
public
get(string $id) : mixed
Parameters
- $id : string
-
Identifier of the entry to look for (typically a class name or interface)
Return values
mixed —Entry.
has()
Returns true if the container can return an entry for the given identifier.
public
has(string $id) : bool
Parameters
- $id : string
-
Identifier of the entry to look for.
Return values
boolinstance()
Register an existing instance as a singleton
public
instance(string $abstract, object $instance) : void
Parameters
- $abstract : string
-
Interface or class name
- $instance : object
-
The instance to register
make()
Resolve and instantiate a class with automatic dependency injection
public
make(string $class[, array<string, mixed> $parameters = [] ]) : object
Parameters
- $class : string
- $parameters : array<string, mixed> = []
Return values
objectsingleton()
Register a singleton (shared instance) in the container
public
singleton(string $abstract, callable $factory) : void
Parameters
- $abstract : string
-
Interface or class name
- $factory : callable
-
Factory function that creates the instance