-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContainerInterface.php
executable file
·49 lines (43 loc) · 1.82 KB
/
ContainerInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace MaplePHP\Container\Interfaces;
/**
* Describes the interface of a container that exposes methods to read its entries.
*/
interface ContainerInterface
{
/**
* Finds an entry of the container by its identifier and returns it.
*
* @param string $identifier Identifier of the entry to look for.
*
* @throws NotFoundExceptionInterface No entry was found for **this** identifier.
* @throws ContainerExceptionInterface Error while retrieving the entry.
*
* @return mixed Entry.
*/
public function get(string $identifier, array $args = []): mixed;
/**
* Returns true if the container can return an entry for the given identifier.
* Returns false otherwise.
*
* `has($identifier)` returning true does not mean that `get($identifier)` will not throw an exception.
* It does however mean that `get($identifier)` will not throw a `NotFoundExceptionInterface`.
*
* @param string $identifier Identifier of the entry to look for.
*
* @return bool
*/
public function has(string $identifier): bool;
/**
* Set a container OR factory
* @param string $identifier Uniq identifier
* @param mixed $value Example:
* TestClasses\Test::class,
* TestClasses\Test::class."::__construct",
* TestClasses\Test::class."::getStaticMethod",
* @param array|null $args Pass argumnets to constructor staticMethod if you choose.
* @param bool|boolean $overwrite Will throw exception if already been defined if not arg is set to TRUE.
*/
public function set(string $identifier, $value, ?array $args = null, bool $overwrite = false): ContainerInterface;
}