1 | <?php |
||
8 | class ServiceContainer |
||
9 | { |
||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | private $parameters = []; |
||
14 | |||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | private $serviceDefinitions = []; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | private $tags = []; |
||
24 | |||
25 | /** |
||
26 | * @param $id |
||
27 | * @return bool |
||
28 | */ |
||
29 | public function hasParameter($id) |
||
33 | |||
34 | /** |
||
35 | * @param $id |
||
36 | * @param $value |
||
37 | */ |
||
38 | public function setParameter($id, $value) |
||
42 | |||
43 | /** |
||
44 | * @param $id |
||
45 | * @return mixed |
||
46 | * @throws \RuntimeException |
||
47 | */ |
||
48 | public function getParameter($id) |
||
56 | |||
57 | /** |
||
58 | * @param $id |
||
59 | * @return bool |
||
60 | */ |
||
61 | public function hasService($id) |
||
65 | |||
66 | |||
67 | public function removeService($id) |
||
73 | |||
74 | /** |
||
75 | * getService($id) will return result of $definition closure. |
||
76 | * Callback will be executed with $this (ServiceContainer) as a argument. |
||
77 | * |
||
78 | * @param $id |
||
79 | * @param callable $definition |
||
80 | * @param array $tags |
||
81 | */ |
||
82 | public function setDefinition($id, \Closure $definition, $tags = []) |
||
87 | |||
88 | /** |
||
89 | * Works just like setDefinition but getService($id) is going to return |
||
90 | * exactly same value every single time. |
||
91 | * |
||
92 | * @param $id |
||
93 | * @param callable $definition |
||
94 | * @param array $tags |
||
95 | */ |
||
96 | public function setStaticDefinition($id, \Closure $definition, $tags = []) |
||
107 | |||
108 | /** |
||
109 | * @param $id |
||
110 | * @return mixed |
||
111 | * @throws \RuntimeException |
||
112 | */ |
||
113 | public function getService($id) |
||
121 | |||
122 | /** |
||
123 | * @param $tag |
||
124 | * @return array |
||
125 | */ |
||
126 | public function getServicesByTag($tag) |
||
137 | } |
||
138 |