Config   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 59
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigModule() 0 6 1
A __construct() 0 6 1
A isMoveAddressBilling() 0 3 1
A isEnabled() 0 3 1
1
<?php
2
/**
3
 * Copyright © O2TI. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See COPYING.txt for license details.
7
 */
8
9
namespace O2TI\ThemeFullCheckout\Helper;
10
11
use Magento\Framework\App\Config\ScopeConfigInterface;
12
use Magento\Framework\App\Helper\AbstractHelper;
13
use Magento\Store\Model\ScopeInterface;
14
use Magento\Store\Model\StoreManagerInterface;
15
16
/**
17
 * Class Config - Helper configuration.
18
 */
19
class Config extends AbstractHelper
20
{
21
    public const CONFIG_PATH_GENERAL = 'theme_full_checkout/general/%s';
22
23
    /**
24
     * @var ScopeConfigInterface
25
     */
26
    protected $scopeConfig;
27
28
    /**
29
     * @var StoreManagerInterface
30
     */
31
    protected $storeManagerInterface;
32
33
    /**
34
     * @param ScopeConfigInterface  $scopeConfig
35
     * @param StoreManagerInterface $storeManagerInterface
36
     */
37
    public function __construct(
38
        ScopeConfigInterface $scopeConfig,
39
        StoreManagerInterface $storeManagerInterface
40
    ) {
41
        $this->scopeConfig = $scopeConfig;
42
        $this->storeManagerInterface = $storeManagerInterface;
43
    }
44
45
    /**
46
     * Get Configs Module.
47
     *
48
     * @param string $field
49
     *
50
     * @return string
51
     */
52
    public function getConfigModule(string $field): ?string
53
    {
54
        $storeId = $this->storeManagerInterface->getStore()->getId();
55
        $configPath = sprintf(self::CONFIG_PATH_GENERAL, $field);
56
57
        return $this->scopeConfig->getValue($configPath, ScopeInterface::SCOPE_STORE, $storeId);
58
    }
59
60
    /**
61
     * If module is Enabled.
62
     *
63
     * @return bool
64
     */
65
    public function isEnabled(): ?bool
66
    {
67
        return $this->getConfigModule('enabled');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getConfigModule('enabled') could return the type string which is incompatible with the type-hinted return boolean|null. Consider adding an additional type-check to rule them out.
Loading history...
68
    }
69
70
    /**
71
     * If module is Move Address Billing.
72
     *
73
     * @return bool
74
     */
75
    public function isMoveAddressBilling(): ?bool
76
    {
77
        return $this->getConfigModule('move_address_billing');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getConfigM...'move_address_billing') could return the type string which is incompatible with the type-hinted return boolean|null. Consider adding an additional type-check to rule them out.
Loading history...
78
    }
79
}
80