Issues (10)

config/di/ipValidator.php (1 issue)

1
<?php
2
3
return [
4
    "services" => [
5
        "ipValidator" => [
6
            "callback" => function () {
7
                $service = new \Teca\IpValidator\IpValidator();
8
                $service->setDi($this);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
9
10
                $cfg = $this->get('configuration');
11
                try {
12
                    $config = $cfg->load('api.php');
13
                    $settings = $config['config'] ?? null;
14
                    $service->setApiKey($settings['ipstackKey']);
15
                } catch (\Exception $e) {
16
                    if (!empty(getenv('ipstackKey'))) {
17
                        $service->setApiKey(getenv('ipstackKey'));
18
                    } else {
19
                        $service->setApiKey('');
20
                    }
21
                }
22
23
                return $service;
24
            }
25
        ],
26
    ],
27
];
28