EnginesCheck   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 42
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B check() 0 23 5
1
<?php
2
3
namespace N98\Magento\Command\System\Check\MySQL;
4
5
use Magento\Framework\App\ResourceConnection;
6
use N98\Magento\Command\System\Check\SimpleCheck;
7
use N98\Magento\Command\System\Check\Result;
8
use N98\Magento\Command\System\Check\ResultCollection;
9
10
class EnginesCheck implements SimpleCheck
11
{
12
    /**
13
     * @var ResourceConnection
14
     */
15
    private $resource;
16
17
    /**
18
     * @param ResourceConnection $resource
19
     */
20
    public function __construct(ResourceConnection $resource)
21
    {
22
        $this->resource = $resource;
23
    }
24
25
    /**
26
     * @param ResultCollection $results
27
     */
28
    public function check(ResultCollection $results)
29
    {
30
        $result = $results->createResult();
31
32
        $dbAdapter = $this->resource->getConnection();
33
34
        $engines = $dbAdapter->fetchAll('SHOW ENGINES');
35
        $innodbFound = false;
36
        foreach ($engines as $engine) {
37
            if (strtolower($engine['Engine']) == 'innodb') {
38
                $innodbFound = true;
39
                break;
40
            }
41
        }
42
43
        $result->setStatus($innodbFound ? Result::STATUS_OK : Result::STATUS_ERROR);
44
45
        if ($innodbFound) {
46
            $result->setMessage("<info>Required MySQL Storage Engine <comment>InnoDB</comment> found.</info>");
47
        } else {
48
            $result->setMessage("<error>Required MySQL Storage Engine \"InnoDB\" not found!</error>");
49
        }
50
    }
51
}
52