1 | <?php |
||
8 | class Bucket implements ContainerInterface |
||
9 | { |
||
10 | /** @var \Closure[] */ |
||
11 | private $factories = []; |
||
12 | |||
13 | /** @var array */ |
||
14 | private $values = []; |
||
15 | |||
16 | /** @var ContainerInterface */ |
||
17 | private $delegateContainer; |
||
18 | |||
19 | public function __construct(array $values = []) |
||
25 | |||
26 | 12 | /** |
|
27 | 9 | * @param string $id |
|
28 | * @param mixed $value |
||
29 | * |
||
30 | 3 | * @return self |
|
31 | */ |
||
32 | 3 | public function add(string $id, $value) |
|
42 | |||
43 | 9 | /** |
|
44 | * @param string $id |
||
45 | 9 | * @param \Closure $value |
|
46 | * |
||
47 | * @return self |
||
48 | */ |
||
49 | public function addFactory(string $id, \Closure $value) |
||
55 | |||
56 | /** |
||
57 | 12 | * @inheritdoc |
|
58 | 9 | */ |
|
59 | public function get($id) |
||
71 | 9 | ||
72 | /** |
||
73 | 9 | * @param string $id |
|
74 | * @return mixed |
||
75 | */ |
||
76 | private function getFromFactory(string $id) |
||
83 | |||
84 | /** |
||
85 | * @inheritdoc |
||
86 | */ |
||
87 | public function has($id): bool |
||
91 | |||
92 | /** |
||
93 | * @param $id |
||
94 | * @return bool |
||
95 | */ |
||
96 | protected function hasFactory(string $id): bool |
||
100 | |||
101 | /** |
||
102 | * @param $id |
||
103 | * @return bool |
||
104 | */ |
||
105 | 3 | protected function hasValue(string $id): bool |
|
109 | |||
110 | /** |
||
111 | * @param ContainerInterface $delegateContainer |
||
112 | */ |
||
113 | public function setDelegateContainer(ContainerInterface $delegateContainer) |
||
117 | } |
||
118 |