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

MageModeCheck::checkEnv()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace N98\Magento\Command\System\Check\Env;
4
5
use N98\Magento\Command\System\Check\Result;
6
7
class MageModeCheck extends CheckAbstract
8
{
9
    /**
10
     * Check if MAGE_MODE has correct value (developer, production or default)
11
     */
12
    public function checkEnv()
13
    {
14
        $result = $this->_results->createResult();
15
        $mageMode = strtolower($this->_env['MAGE_MODE']);
16
        if (in_array($mageMode, ['developer', 'production', 'default'])) {
17
            $status = Result::STATUS_OK;
18
            $message = '<info><comment>MAGE_MODE</comment> has correct value.</info>';
19
        } else {
20
            $status = Result::STATUS_ERROR;
21
            $message = "<error><comment>MAGE_MODE</comment> has incorrect value. It should be either 'developer', 'production' or 'default'. Your value: <comment>$mageMode</comment></error>";
22
        }
23
24
        $result->setStatus($status);
25
        $result->setMessage($message);
26
    }
27
}
28