Passed
Pull Request — master (#48)
by
unknown
04:00
created

WcPagantisExtraConfig::getExtraConfigValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
4
5
class WcPagantisExtraConfig
6
{
7
8
    /** @var array $extraConfig */
9
    public $extraConfig;
10
11
12
13
    public static function getExtraConfigValue($key)
14
    {
15
        include_once('class-wc-pagantis-logger.php');
16
        $config = self::getExtraConfig();
17
        $value = $config[$key];
18
        WCPagantisLogger::writeLog($value);
19
        return $value;
20
    }
21
22
    /**
23
     * @return array
24
     */
25
    private static function getExtraConfig()
26
    {
27
        global $wpdb;
28
        $tableName = $wpdb->prefix.PAGANTIS_CONFIG_TABLE;
29
        $response = array();
30
        $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A);
0 ignored issues
show
Bug introduced by
The constant ARRAY_A was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
31
        foreach ($dbResult as $value) {
32
            $response[$value['config']] = $value['value'];
33
        }
34
35
        return $response;
36
    }
37
}
38
39
/**
40
 * @todo remove this is for debug
41
 */
42
WcPagantisExtraConfig::getExtraConfigValue('PAGANTIS_PROMOTION_EXTRA');
43
WcPagantisExtraConfig::getExtraConfigValue('PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR');
44
WcPagantisExtraConfig::getExtraConfigValue('PAGANTIS_SIMULATOR_DISPLAY_SKIN');
45
WCPagantisLogger::writeLog(WcPagantisExtraConfig::getExtraConfigValue('PAGANTIS_SIMULATOR_DISPLAY_SKIN'));
46
WCPagantisLogger::writeLog(WcPagantisExtraConfig::getExtraConfigValue('PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'));
47