AsaTirsen /
weather
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Configuration file for DI container. |
||
| 4 | */ |
||
| 5 | |||
| 6 | return [ |
||
| 7 | |||
| 8 | // Services to add to the container. |
||
| 9 | "services" => [ |
||
| 10 | "weather" => [ |
||
| 11 | // Is the service shared, true or false |
||
| 12 | // Optional, default is true |
||
| 13 | "shared" => true, |
||
| 14 | |||
| 15 | // Callback executed when service is activated |
||
| 16 | // Create the service, load its configuration (if any) |
||
| 17 | // and set it up. |
||
| 18 | "callback" => function () { |
||
| 19 | $weatherService = new \Asti\Weather\WeatherService(); |
||
| 20 | |||
| 21 | // Load the configuration files |
||
| 22 | $cfg = $this->get("configuration"); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 23 | $config = $cfg->load("weather.php"); |
||
| 24 | $settings = $config["config"] ?? null; |
||
| 25 | |||
| 26 | if ($settings["url"] ?? null) { |
||
| 27 | $weatherService->setUrl($settings["url"]); |
||
| 28 | } |
||
| 29 | if ($settings["WEATHERAPIKEY"] ?? null) { |
||
| 30 | $weatherService->setKey($settings["WEATHERAPIKEY"]); |
||
| 31 | } |
||
| 32 | |||
| 33 | return $weatherService; |
||
| 34 | } |
||
| 35 | ], |
||
| 36 | ], |
||
| 37 | ]; |
||
| 38 |