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

ExtraConfig   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 11
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getExtraConfig() 0 12 3
A __construct() 0 3 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
        $result = $dbConnection->fetchAll("select * from ".self::CONFIG_TABLE);
37
        if (count($result)) {
38
            foreach ($result as $value) {
39
                $data[$value['config']] = $value['value'];
40
            }
41
        }
42
43
        return $data;
44
    }
45
}