1 | <?php |
||
13 | class Environment |
||
14 | { |
||
15 | const DEPLOY_PATH = 'deploy_path'; |
||
16 | |||
17 | /** |
||
18 | * Array of set values. |
||
19 | * @var Collection |
||
20 | */ |
||
21 | private $values = null; |
||
22 | |||
23 | /** |
||
24 | * Values represented by their keys here are protected, and cannot be |
||
25 | * changed by calling the `set` method. |
||
26 | * @var array |
||
27 | */ |
||
28 | private $protectedNames = []; |
||
29 | |||
30 | /** |
||
31 | * Constructor |
||
32 | */ |
||
33 | public function __construct() |
||
37 | |||
38 | /** |
||
39 | 53 | * @return Collection |
|
40 | */ |
||
41 | 53 | public function getValues() |
|
45 | |||
46 | /** |
||
47 | * @param string $name |
||
48 | 37 | * @param bool|int|string|array $value |
|
49 | */ |
||
50 | 37 | public function set($name, $value) |
|
55 | |||
56 | /** |
||
57 | * @param string $name |
||
58 | 25 | * @param bool|int|string|array $value |
|
59 | */ |
||
60 | 25 | public function setAsProtected($name, $value) |
|
65 | |||
66 | /** |
||
67 | * Checks whether the given name was registered as protected, or if there is |
||
68 | * a protected parameter which would be overwritten. |
||
69 | * @param string $name |
||
70 | * @throws \RuntimeException if the value already exists and is protected. |
||
71 | * @throws \RuntimeException if there's a protected parameter which would |
||
72 | 37 | * be overwritten. |
|
73 | */ |
||
74 | 37 | private function checkIfNameIsProtected($name) |
|
89 | |||
90 | /** |
||
91 | * @param string $name |
||
92 | * @param array $array |
||
93 | */ |
||
94 | 24 | public function add($name, $array) |
|
106 | 18 | ||
107 | 1 | /** |
|
108 | * @param string $name |
||
109 | 18 | * @param bool|int|string|array $default |
|
110 | * @return bool|int|string|array |
||
111 | * @throws \RuntimeException |
||
112 | */ |
||
113 | public function get($name, $default = null) |
||
141 | |||
142 | /** |
||
143 | * Checks if set var exists. |
||
144 | 15 | * |
|
145 | * @param string $name |
||
146 | 15 | * @return bool |
|
147 | 1 | */ |
|
148 | 1 | public function has($name) |
|
152 | |||
153 | /** |
||
154 | * Parse set values. |
||
155 | * |
||
156 | * @param string $value |
||
157 | * @return string |
||
158 | 25 | */ |
|
159 | public function parse($value) |
||
167 | |||
168 | /** |
||
169 | * Replace set values callback for parse |
||
170 | * |
||
171 | * @param array $matches |
||
172 | * @return mixed |
||
173 | 16 | */ |
|
174 | private function parseCallback($matches) |
||
178 | |||
179 | /** |
||
180 | * @param mixed $t |
||
181 | * @return bool |
||
182 | */ |
||
183 | private function isClosure($t) |
||
187 | } |
||
188 |