Completed
Push — master ( 36e8c5...2454a8 )
by Tom
12:20 queued 07:25
created

EnginesCheck::check()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 22
rs 8.6737
cc 5
eloc 14
nc 6
nop 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A EnginesCheck::checkImplementation() 0 14 2
1
<?php
2
/*
3
 * this file is part of magerun
4
 *
5
 * @author Tom Klingenberg <https://github.com/ktomk>
6
 */
7
8
namespace N98\Magento\Command\System\Check\MySQL;
9
10
use N98\Magento\Command\System\Check\Result;
11
use Varien_Db_Adapter_Interface;
12
13
class EnginesCheck extends ResourceCheck
14
{
15
    /**
16
     * @param Result $result
17
     * @param Varien_Db_Adapter_Interface $dbAdapter
18
     * @return void
19
     */
20
    protected function checkImplementation(Result $result, Varien_Db_Adapter_Interface $dbAdapter)
21
    {
22
        $innodbFound = $this->checkInnodbEngine($dbAdapter);
23
24
        if ($innodbFound) {
25
            $result->setStatus(Result::STATUS_OK);
26
            $result->setMessage("<info>Required MySQL Storage Engine <comment>InnoDB</comment> found.</info>");
27
        } else {
28
            $result->setStatus(Result::STATUS_ERROR);
29
            $result->setMessage(
30
                "<error>Required MySQL Storage Engine <comment>InnoDB</comment> not found!</error>"
31
            );
32
        }
33
    }
34
35
    /**
36
     * @param Varien_Db_Adapter_Interface $dbAdapter
37
     * @return bool
38
     */
39
    private function checkInnodbEngine(Varien_Db_Adapter_Interface $dbAdapter)
40
    {
41
        $innodbFound = false;
42
43
        $engines = $dbAdapter->fetchAll('SHOW ENGINES');
44
45
        foreach ($engines as $engine) {
46
            if (strtolower($engine['Engine']) === 'innodb') {
47
                $innodbFound = true;
48
                break;
49
            }
50
        }
51
52
        return $innodbFound;
53
    }
54
}
55