Completed
Push — master ( cda577...82aa13 )
by Christian
02:25
created

KeyExistsCheck::envKeyExist()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace N98\Magento\Command\System\Check\Env;
4
5
use N98\Magento\Command\System\Check\Result;
6
7
class KeyExistsCheck extends CheckAbstract
8
{
9
    /**
10
     * Check if env keys exists
11
     */
12
    public function checkEnv()
13
    {
14
        $requiredKeys = $this->_commandConfig['env']['required-keys'];
15
        foreach ($requiredKeys as $key => $value) {
16
            $this->envKeyExist($value);
17
        }
18
    }
19
20
    /**
21
     * Check if env key exists
22
     *
23
     * @param string $key
24
     */
25
    protected function envKeyExist($key)
26
    {
27
        $result = $this->_results->createResult();
28
        if ($this->_dot->has($key)) {
29
            $status = Result::STATUS_OK;
30
            $message = '<info>Key <comment>' . $key . '</comment> found.</info>';
31
        } else {
32
            $status = Result::STATUS_ERROR;
33
            $message = '<error>Key <comment>' . $key . '</comment> not found!</error>';
34
        }
35
36
        $result->setStatus($status);
37
        $result->setMessage($message);
38
    }
39
}
40