Completed
Push — master ( 8cfecb...049017 )
by Marcel
04:09
created

ExampleEnvironmentVariablesAreUpToDate::message()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace BeyondCode\SelfDiagnosis\Checks;
4
5
use Dotenv\Dotenv;
6
use Illuminate\Support\Collection;
7
8 View Code Duplication
class ExampleEnvironmentVariablesAreUpToDate implements Check
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /** @var Collection */
11
    private $envVariables;
12
13
    /**
14
     * The name of the check.
15
     *
16
     * @param array $config
17
     * @return string
18
     */
19
    public function name(array $config): string
20
    {
21
        return trans('self-diagnosis::checks.example_environment_variables_are_up_to_date.name');
22
    }
23
24
    /**
25
     * Perform the actual verification of this check.
26
     *
27
     * @param array $config
28
     * @return bool
29
     */
30
    public function check(array $config): bool
31
    {
32
        $examples = new Dotenv(base_path(), '.env.example');
33
        $examples->safeLoad();
34
35
        $actual = new Dotenv(base_path(), '.env');
36
        $actual->safeLoad();
37
38
        $this->envVariables = Collection::make($actual->getEnvironmentVariableNames())
39
            ->diff($examples->getEnvironmentVariableNames());
40
41
        return $this->envVariables->isEmpty();
42
    }
43
44
    /**
45
     * The error message to display in case the check does not pass.
46
     *
47
     * @param array $config
48
     * @return string
49
     */
50
    public function message(array $config): string
51
    {
52
        return trans('self-diagnosis::checks.example_environment_variables_are_up_to_date.message', [
53
            'variables' => $this->envVariables->implode(PHP_EOL),
54
        ]);
55
    }
56
}
57