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