1 | <?php |
||
21 | class Environment implements EnvironmentInterface |
||
22 | { |
||
23 | /** |
||
24 | * Environment section. |
||
25 | */ |
||
26 | const MEMORY = 'environment'; |
||
27 | |||
28 | /** |
||
29 | * Environment filename. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private $filename = ''; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $id = ''; |
||
39 | |||
40 | /** |
||
41 | * @var array |
||
42 | */ |
||
43 | private $values = []; |
||
44 | |||
45 | /** |
||
46 | * @invisible |
||
47 | * @var FilesInterface |
||
48 | */ |
||
49 | protected $files = null; |
||
50 | |||
51 | /** |
||
52 | * @invisible |
||
53 | * @var MemoryInterface |
||
54 | */ |
||
55 | protected $memory = null; |
||
56 | |||
57 | /** |
||
58 | * @param string $filename |
||
59 | * @param FilesInterface $files |
||
60 | * @param MemoryInterface $memory |
||
61 | * |
||
62 | * @throws EnvironmentException |
||
63 | */ |
||
64 | public function __construct(string $filename, FilesInterface $files, MemoryInterface $memory) |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | public function getID(): string |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | * |
||
84 | * @return $this |
||
85 | */ |
||
86 | public function set(string $name, $value): Environment |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function get(string $name, $default = null) |
||
105 | |||
106 | /** |
||
107 | * Fetch environment values from .evn file. |
||
108 | * |
||
109 | * @param string $filename |
||
110 | * |
||
111 | * @return array |
||
112 | */ |
||
113 | protected function parseValues($filename) |
||
120 | |||
121 | /** |
||
122 | * Load environment data. |
||
123 | * |
||
124 | * @throws EnvironmentException |
||
125 | */ |
||
126 | protected function load() |
||
149 | |||
150 | /** |
||
151 | * Initiate environment values. |
||
152 | * |
||
153 | * @param array $values |
||
154 | * |
||
155 | * @return array |
||
156 | */ |
||
157 | protected function initEnvironment(array $values): array |
||
167 | |||
168 | /** |
||
169 | * Normalize env value. |
||
170 | * |
||
171 | * @param mixed $value |
||
172 | * |
||
173 | * @return bool|null|string |
||
174 | */ |
||
175 | private function normalize($value) |
||
197 | } |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.