Total Complexity | 9 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class AggregateEnv implements EnvInterface |
||
8 | { |
||
9 | protected $extensions = []; |
||
10 | |||
11 | public function __construct(EnvInterface ...$envs) |
||
12 | { |
||
13 | while ($env = array_pop($envs)) { |
||
14 | $this->extensions[] = $env; |
||
15 | } |
||
16 | } |
||
17 | |||
18 | public function __isset($prop): bool |
||
19 | { |
||
20 | foreach ($this->extensions as $extension) { |
||
21 | if (isset($extension->$prop)) { |
||
22 | return true; |
||
23 | } |
||
24 | } |
||
25 | return false; |
||
26 | } |
||
27 | |||
28 | public function extend(EnvInterface $extension) |
||
29 | { |
||
30 | $new = clone $this; |
||
31 | array_unshift($new->extensions, $extension); |
||
32 | return $new; |
||
33 | } |
||
34 | |||
35 | public function __get(string $prop) |
||
44 | } |
||
45 | } |