1 | <?php |
||
13 | final class ProxyContainer implements ContainerInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | private $mocks; |
||
19 | |||
20 | /** |
||
21 | * ProxyContainer constructor. |
||
22 | */ |
||
23 | 12 | public function __construct() |
|
27 | |||
28 | /** |
||
29 | * @param string $id |
||
30 | * @return ProxyInterface |
||
31 | * |
||
32 | * @throws InvalidIdentifierException |
||
33 | */ |
||
34 | 8 | public function get($id): ProxyInterface |
|
35 | { |
||
36 | 8 | if (!$this->has($id)) { |
|
37 | 1 | throw new InvalidIdentifierException( |
|
38 | 1 | sprintf( |
|
39 | 1 | 'Cannot find mock object with identifier "%s"', |
|
40 | $id |
||
41 | ) |
||
42 | ); |
||
43 | } |
||
44 | |||
45 | 7 | return $this->mocks[$id]; |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param string $id |
||
50 | * @return bool |
||
51 | */ |
||
52 | 13 | public function has($id): bool |
|
56 | |||
57 | /** |
||
58 | * @param string $id |
||
59 | * @param ProxyInterface $mock |
||
60 | */ |
||
61 | 10 | public function set(string $id, ProxyInterface $mock) |
|
65 | } |
||
66 |