Environment   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 18
c 1
b 0
f 0
dl 0
loc 35
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B call() 0 27 8
1
<?php
2
namespace Health\Checks\Env;
3
4
use Health\Checks\BaseCheck;
5
use Health\Checks\HealthCheckInterface;
6
7
class Environment 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 = env($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