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

ResourceCheck::check()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
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 Mage;
11
use Mage_Core_Model_Resource;
12
use N98\Magento\Command\System\Check\Result;
13
use N98\Magento\Command\System\Check\ResultCollection;
14
use N98\Magento\Command\System\Check\SimpleCheck;
15
use Varien_Db_Adapter_Interface;
16
17
abstract class ResourceCheck implements SimpleCheck
18
{
19
    /**
20
     * @param ResultCollection $results
21
     */
22
    public function check(ResultCollection $results)
23
    {
24
        /** @var $resourceModel Mage_Core_Model_Resource */
25
        $resourceModel = Mage::getModel('core/resource');
26
27
        /** @var $dbAdapter Varien_Db_Adapter_Interface|false */
28
        $dbAdapter = $resourceModel->getConnection('core_write');
29
30
        $result = $results->createResult();
31
32
        if (!$dbAdapter instanceof Varien_Db_Adapter_Interface) {
0 ignored issues
show
Bug introduced by
The class Varien_Db_Adapter_Interface does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
33
            $result->setStatus($result::STATUS_ERROR);
34
            $result->setMessage(
35
                "<error>Mysql Version: Can not check. Unable to obtain resource connection 'core_write'.</error>"
36
            );
37
        } else {
38
            $this->checkImplementation($result, $dbAdapter);
39
        }
40
    }
41
42
    /**
43
     * @param Result $result
44
     * @param Varien_Db_Adapter_Interface $dbAdapter
45
     * @return void
46
     */
47
    abstract protected function checkImplementation(Result $result, Varien_Db_Adapter_Interface $dbAdapter);
48
}
49