| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\Vendors\StellarWP\ContainerContract; |
| 4 |
|
| 5 |
/** |
| 6 |
* Describes the interface of a container that exposes methods to read its entries. |
| 7 |
*/ |
| 8 |
interface ContainerInterface { |
| 9 |
/** |
| 10 |
* Binds an interface, a class or a string slug to an implementation. |
| 11 |
* |
| 12 |
* Existing implementations are replaced. |
| 13 |
* |
| 14 |
* @param string $id Identifier of the entry to look for. |
| 15 |
* @param mixed $implementation The implementation that should be bound to the alias(es); can be a |
| 16 |
* class name, an object or a closure. |
| 17 |
* |
| 18 |
* @return mixed Entry. |
| 19 |
*/ |
| 20 |
public function bind( string $id, $implementation = null ); |
| 21 |
|
| 22 |
/** |
| 23 |
* Finds an entry of the container by its identifier and returns it. |
| 24 |
* |
| 25 |
* @param string $id Identifier of the entry to look for. |
| 26 |
* |
| 27 |
* @return mixed Entry. |
| 28 |
*/ |
| 29 |
public function get( string $id ); |
| 30 |
|
| 31 |
/** |
| 32 |
* Returns true if the container can return an entry for the given identifier. |
| 33 |
* Returns false otherwise. |
| 34 |
* |
| 35 |
* `has($id)` returning true does not mean that `get($id)` will not throw an exception. |
| 36 |
* It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`. |
| 37 |
* |
| 38 |
* @param string $id Identifier of the entry to look for. |
| 39 |
* |
| 40 |
* @return bool |
| 41 |
*/ |
| 42 |
public function has( string $id ); |
| 43 |
|
| 44 |
/** |
| 45 |
* Binds an interface a class or a string slug to an implementation and will always return the same instance. |
| 46 |
* |
| 47 |
* @param string $id Identifier of the entry to look for. |
| 48 |
* @param mixed $implementation The implementation that should be bound to the alias(es); can be a |
| 49 |
* class name, an object or a closure. |
| 50 |
* |
| 51 |
* @return void This method does not return any value. |
| 52 |
*/ |
| 53 |
public function singleton( string $id, $implementation = null ); |
| 54 |
} |
| 55 |
|