ExtraConfig   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getExtraConfig() 0 15 4
A __construct() 0 3 1
1
<?php
2
3
namespace Pagantis\Pagantis\Helper;
4
5
use Magento\Framework\App\ResourceConnection;
6
7
/**
8
 * Class ExtraConfig
9
 * @package Pagantis\Pagantis\Helper
10
 */
11
class ExtraConfig
12
{
13
    /** Config tablename */
14
    const CONFIG_TABLE = 'Pagantis_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
        $prefixedTableName = $dbConnection->getTableName(self::CONFIG_TABLE);
37
        if ($dbConnection->isTableExists($prefixedTableName)) {
38
            $result = $dbConnection->fetchAll("select * from $prefixedTableName");
39
            if (count($result)) {
40
                foreach ($result as $value) {
41
                    $data[$value['config']] = $value['value'];
42
                }
43
            }
44
        }
45
46
        return $data;
47
    }
48
}