ExtensionsCheck::check()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 14
rs 9.2
c 1
b 0
f 0
cc 4
eloc 9
nc 3
nop 1
1
<?php
2
3
namespace N98\Magento\Command\System\Check\PHP;
4
5
use N98\Magento\Command\CommandConfigAware;
6
use N98\Magento\Command\System\Check\Result;
7
use N98\Magento\Command\System\Check\ResultCollection;
8
use N98\Magento\Command\System\Check\SimpleCheck;
9
10
class ExtensionsCheck implements SimpleCheck, CommandConfigAware
11
{
12
    /**
13
     * @var array
14
     */
15
    protected $_commandConfig;
16
17
    /**
18
     * @param ResultCollection $results
19
     */
20
    public function check(ResultCollection $results)
21
    {
22
        $requiredExtensions = $this->_commandConfig['php']['required-extensions'];
23
24
        foreach ($requiredExtensions as $ext) {
25
            $result = $results->createResult();
26
            $result->setStatus(extension_loaded($ext) ? Result::STATUS_OK : Result::STATUS_ERROR);
27
            if ($result->isValid()) {
28
                $result->setMessage("<info>Required PHP Module <comment>$ext</comment> found.</info>");
29
            } else {
30
                $result->setMessage("<error>Required PHP Module $ext not found!</error>");
31
            }
32
        }
33
    }
34
35
    /**
36
     * @param array $commandConfig
37
     */
38
    public function setCommandConfig(array $commandConfig)
39
    {
40
        $this->_commandConfig = $commandConfig;
41
    }
42
}
43