ServiceCollectionInterface
extends
ServiceProviderInterface, Countable, IteratorAggregate
in
A ServiceProviderInterface that is also countable and iterable.
Tags
Table of Contents
Methods
- get() : T
- Finds an entry of the container by its identifier and returns it.
- getProvidedServices() : array<string, string>
- Returns an associative array of service types keyed by the identifiers provided by the current container.
- has() : bool
- Returns true if the container can return an entry for the given identifier.
Methods
get()
Finds an entry of the container by its identifier and returns it.
public
get(string $id) : T
Parameters
- $id : string
-
Identifier of the entry to look for.
Return values
TgetProvidedServices()
Returns an associative array of service types keyed by the identifiers provided by the current container.
public
getProvidedServices() : array<string, string>
Examples:
- ['logger' => 'Psr\Log\LoggerInterface'] means the object provides a service named "logger" that implements Psr\Log\LoggerInterface
- ['foo' => '?'] means the container provides service name "foo" of unspecified type
- ['bar' => '?Bar\Baz'] means the container provides a service "bar" of type Bar\Baz|null
Return values
array<string, string> —The provided service types, keyed by service names
has()
Returns true if the container can return an entry for the given identifier.
public
has(string $id) : bool
Returns false otherwise.
has($id)
returning true does not mean that get($id)
will not throw an exception.
It does however mean that get($id)
will not throw a NotFoundExceptionInterface
.
Parameters
- $id : string
-
Identifier of the entry to look for.