1 | <?php |
||
13 | class Environment |
||
14 | { |
||
15 | const DEPLOY_PATH = 'deploy_path'; |
||
16 | |||
17 | /** |
||
18 | * Array of set values. |
||
19 | * @var \Deployer\Type\DotArray |
||
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 | * @param string $name |
|
40 | * @param bool|int|string|array $value |
||
41 | 53 | */ |
|
42 | 53 | public function set($name, $value) |
|
47 | |||
48 | 37 | /** |
|
49 | * @param string $name |
||
50 | 37 | * @param bool|int|string|array $value |
|
51 | 37 | */ |
|
52 | 37 | public function setAsProtected($name, $value) |
|
57 | |||
58 | 25 | /** |
|
59 | * Checks whether the given name was registered as protected, or if there is |
||
60 | 25 | * a protected parameter which would be overwritten. |
|
61 | 25 | * @param string $name |
|
62 | 25 | * @throws \RuntimeException if the value already exists and is protected. |
|
63 | * @throws \RuntimeException if there's a protected parameter which would |
||
64 | * be overwritten. |
||
65 | */ |
||
66 | private function checkIfNameIsProtected($name) |
||
81 | 2 | ||
82 | 17 | /** |
|
83 | 1 | * @param string $name |
|
84 | * @param array $array |
||
85 | 37 | */ |
|
86 | 37 | public function add($name, $array) |
|
98 | 22 | ||
99 | 18 | /** |
|
100 | 11 | * @param string $name |
|
101 | 11 | * @param bool|int|string|array $default |
|
102 | 11 | * @return bool|int|string|array |
|
103 | 5 | * @throws \RuntimeException |
|
104 | */ |
||
105 | 11 | public function get($name, $default = null) |
|
133 | |||
134 | 2 | /** |
|
135 | * Checks if set var exists. |
||
136 | * |
||
137 | 2 | * @param string $name |
|
138 | * @return bool |
||
139 | */ |
||
140 | public function has($name) |
||
144 | 15 | ||
145 | /** |
||
146 | 15 | * Parse set values. |
|
147 | 1 | * |
|
148 | 1 | * @param string $value |
|
149 | 15 | * @return string |
|
150 | 15 | */ |
|
151 | public function parse($value) |
||
159 | |||
160 | 25 | /** |
|
161 | 22 | * Replace set values callback for parse |
|
162 | 22 | * |
|
163 | * @param array $matches |
||
164 | 25 | * @return mixed |
|
165 | */ |
||
166 | private function parseCallback($matches) |
||
170 | |||
171 | /** |
||
172 | * @param mixed $t |
||
173 | 16 | * @return bool |
|
174 | */ |
||
175 | 16 | private function isClosure($t) { |
|
178 | } |
||
179 |