1 | <?php |
||
2 | /** |
||
3 | * Configuration file for DI container. |
||
4 | */ |
||
5 | return [ |
||
6 | "services" => [ |
||
7 | "weather" => [ |
||
8 | "shared" => true, |
||
9 | "active" => false, |
||
10 | "callback" => function () { |
||
11 | $weatherModel = new \Jenel\Weather\WeatherModel(); |
||
12 | |||
13 | $cfg = $this->get("configuration"); |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
14 | $config = $cfg->load("weather.php"); |
||
15 | |||
16 | $dataset = $config["config"] ?? null; |
||
17 | if (!$dataset) { |
||
18 | throw new Exception("Configuration file '$config' is missing."); |
||
19 | } |
||
20 | $weatherModel->setConfig($config['config']); |
||
21 | return $weatherModel; |
||
22 | } |
||
23 | ], |
||
24 | ], |
||
25 | ]; |
||
26 |