1 | <?php |
||
10 | class Container implements \IteratorAggregate |
||
11 | { |
||
12 | |||
13 | /** @var string */ |
||
14 | private $class; |
||
15 | |||
16 | /** @var array */ |
||
17 | private $parameters = []; |
||
18 | |||
19 | private $services = []; |
||
20 | |||
21 | |||
22 | 1 | public function getClass() |
|
26 | |||
27 | |||
28 | 3 | public function setClass($class) |
|
32 | |||
33 | |||
34 | 2 | public function getParameter($name) |
|
35 | { |
||
36 | 2 | if (!array_key_exists($name, $this->parameters)) { |
|
37 | 1 | throw new \Exception("Config key '$name' does not exists."); |
|
38 | } |
||
39 | 1 | return $this->parameters[$name]; |
|
40 | } |
||
41 | |||
42 | |||
43 | 2 | public function getParameters() |
|
47 | |||
48 | |||
49 | 3 | public function setParameter($name, $value) |
|
53 | |||
54 | |||
55 | 3 | public function setParameters($parameters) |
|
59 | |||
60 | |||
61 | 2 | public function getServices() |
|
65 | |||
66 | |||
67 | 2 | public function getService($name) |
|
68 | { |
||
69 | 2 | if (!isset($this->services[$name])) { |
|
70 | 1 | throw new \Exception("Service '$name' does not exists."); |
|
71 | } |
||
72 | 1 | return $this->services[$name]; |
|
73 | } |
||
74 | |||
75 | |||
76 | 1 | public function hasService($name) |
|
77 | { |
||
78 | 1 | return isset($this->services[$name]); |
|
79 | } |
||
80 | |||
81 | |||
82 | 2 | public function addService($name, $service) |
|
86 | |||
87 | |||
88 | 1 | public function getIterator() |
|
92 | |||
93 | |||
94 | 1 | public function &__get($name) |
|
98 | |||
99 | |||
100 | 1 | public function __set($name, $value) |
|
104 | |||
105 | } |