Config::call()   B
last analyzed

Complexity

Conditions 8
Paths 25

Size

Total Lines 27
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 27
rs 8.4444
cc 8
nc 25
nop 0
1
<?php
2
namespace Health\Checks\Env;
3
4
use Health\Checks\BaseCheck;
5
use Health\Checks\HealthCheckInterface;
6
7
class Config extends BaseCheck implements HealthCheckInterface
8
{
9
10
    /**
11
     *
12
     * {@inheritdoc}
13
     * @see \Health\Checks\HealthCheckInterface::call()
14
     */
15
    public function call()
16
    {
17
        $builder = $this->getBuilder();
18
19
        foreach ($this->params as $paramKey => $paramValue) {
20
            $variable = is_numeric($paramKey) ? $paramValue : $paramKey;
21
            $expectedValue = is_numeric($paramKey) ? null : $paramValue;
22
            $checkValue = is_numeric($paramKey) ? false : true;
23
24
            $value = config($variable, null);
25
26
            if ($value === null) {
27
                $builder->down();
28
            } else {
29
                if ($checkValue && $value !== $expectedValue) {
30
                    $builder->down();
31
                } else {
32
                    $builder->up();
33
                }
34
            }
35
36
            $builder->withData('variable', $variable)
37
                ->withData('value', $value)
38
                ->withData('value_expected', $expectedValue);
39
        }
40
41
        return $builder->build();
42
    }
43
}
44