1 | <?php |
||
16 | class Environment implements ConfigInterface |
||
17 | { |
||
18 | /** |
||
19 | * DELIMITER |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | const DEFAULT_DELIMITER = '_'; |
||
24 | |||
25 | |||
26 | /** |
||
27 | * Store |
||
28 | * |
||
29 | * @var Config |
||
30 | */ |
||
31 | private $store; |
||
32 | |||
33 | |||
34 | /** |
||
35 | * Variable delimiter |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $delimiter = self::DEFAULT_DELIMITER; |
||
40 | |||
41 | |||
42 | /** |
||
43 | * Variable prefix |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $prefix; |
||
48 | |||
49 | |||
50 | /** |
||
51 | * Load config |
||
52 | * |
||
53 | * @param string $prefix |
||
54 | * @param string $delimiter |
||
55 | * @param array $variables |
||
56 | * @return void |
||
|
|||
57 | */ |
||
58 | public function __construct(?string $prefix=null, $delimiter=self::DEFAULT_DELIMITER, array $variables=[]) |
||
69 | |||
70 | |||
71 | /** |
||
72 | * Get from config |
||
73 | * |
||
74 | * @param string $name |
||
75 | * @return mixed |
||
76 | */ |
||
77 | public function __get(string $name) |
||
81 | |||
82 | |||
83 | /** |
||
84 | * Return map |
||
85 | * |
||
86 | * @return Config |
||
87 | */ |
||
88 | public function map(): Config |
||
92 | |||
93 | |||
94 | /** |
||
95 | * Transform array of environment variables into a tree |
||
96 | * |
||
97 | * @param array $variables |
||
98 | * @return Config |
||
99 | */ |
||
100 | protected function variablesToTree(array $variables): Config |
||
142 | } |
||
143 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.