Passed
Pull Request — master (#16)
by
unknown
03:28
created

ExtraConfig::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace DigitalOrigin\Pmt\Helper;
4
5
use Magento\Framework\App\ResourceConnection;
6
7
/**
8
 * Class ExtraConfig
9
 * @package DigitalOrigin\Pmt\Helper
10
 */
11
class ExtraConfig
12
{
13
    /** Config tablename */
14
    const CONFIG_TABLE = 'pmt_config';
15
16
    /** @var ResourceConnection $dbObject */
17
    protected $dbObject;
18
19
    /**
20
     * ExtraConfig constructor.
21
     *
22
     * @param ResourceConnection $resource
23
     */
24
    public function __construct(ResourceConnection $resource)
25
    {
26
        $this->dbObject = $resource;
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function getExtraConfig()
33
    {
34
        $data = array();
35
        $dbConnection = $this->dbObject->getConnection();
36
        $tableName = self::CONFIG_TABLE;
37
        if ($dbConnection->isTableExists($tableName)) {
38
            $result = $dbConnection->fetchAll("select * from $tableName");
39
            if (count($result)) {
40
                foreach ($result as $value) {
41
                    $data[$value['config']] = $value['value'];
42
                }
43
            }
44
        }
45
46
        return $data;
47
    }
48
}