Completed
Pull Request — master (#1)
by
unknown
12:52
created

StockbaseConfiguration::getEnvironment()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 4
rs 10
ccs 1
cts 1
cp 1
crap 2
1
<?php
2
3
namespace Stockbase\Integration\Model\Config;
4
5
use Magento\Framework\App\Config\ScopeConfigInterface;
6
use Stockbase\Integration\Model\Config\Source\Environment;
7
8
/**
9
 * Stockbase main mobule configuration resource wrapper.
10
 */
11
class StockbaseConfiguration
12
{
13
14
    const CONFIG_MODULE_ENABLED = 'stockbase/integration/module_enabled';
15
    const CONFIG_ENVIRONMENT = 'stockbase/integration/environment';
16
    const CONFIG_USERNAME = 'stockbase/integration/username';
17
    const CONFIG_PASSWORD = 'stockbase/integration/password';
18
    const CONFIG_EAN_FIELD = 'stockbase/integration/ean_field';
19
    const CONFIG_ORDER_PREFIX = 'stockbase/integration/order_prefix';
20
    const CONFIG_IMAGES_SYNC = 'stockbase/integration/images_sync_enabled';
21
    const CONFIG_IMAGES_EANS = 'stockbase/integration/images_eans';
22
23
    /**
24
     * @var ScopeConfigInterface
25
     */
26
    private $scopeConfig;
27
28
    /**
29
     * StockbaseConfiguration constructor.
30 2
     * @param ScopeConfigInterface $scopeConfig
31
     */
32 2
    public function __construct(ScopeConfigInterface $scopeConfig)
33 2
    {
34
        $this->scopeConfig = $scopeConfig;
35
    }
36
37
    /**
38 2
     * @return bool
39
     */
40 2
    public function isModuleEnabled()
41
    {
42
        return (bool) $this->scopeConfig->getValue(self::CONFIG_MODULE_ENABLED);
43
    }
44
45
    /**
46
     * Gets Stockbase environment name.
47
     *
48 2
     * @return string
49
     */
50 2
    public function getEnvironment()
51
    {
52
        return $this->scopeConfig->getValue(self::CONFIG_ENVIRONMENT) ?: Environment::STAGING;
53
    }
54
55
    /**
56 2
     * @return string
57
     */
58 2
    public function getUsername()
59
    {
60
        return $this->scopeConfig->getValue(self::CONFIG_USERNAME);
61
    }
62
63
    /**
64 2
     * @return string
65
     */
66 2
    public function getPassword()
67
    {
68
        return $this->scopeConfig->getValue(self::CONFIG_PASSWORD);
69
    }
70
71
    /**
72 2
     * @return string
73
     */
74 2
    public function getEanFieldName()
75
    {
76
        return $this->scopeConfig->getValue(self::CONFIG_EAN_FIELD);
77
    }
78
79
    /**
80 2
     * @return string
81
     */
82 2
    public function getOrderPrefix()
83
    {
84
        return $this->scopeConfig->getValue(self::CONFIG_ORDER_PREFIX);
85
    }
86
87
    /**
88
     * @return bool
89
     */
90
    public function isImagesSyncEnabled()
91
    {
92
        return (bool) $this->scopeConfig->getValue(self::CONFIG_IMAGES_SYNC);
93
    }
94
95
    /**
96
     * @return mixed
97
     */
98
    public function getImagesEans()
99
    {
100
        return $this->scopeConfig->getValue(self::CONFIG_IMAGES_EANS);
101
    }
102
103
    /**
104
     * @return mixed
105
     */
106
    public function saveImagesEans($eans)
107
    {
108
        return $this->scopeConfig->saveConfig(self::CONFIG_IMAGES_EANS, $eans, 'default', 0);
109
    }
110
111
}
112