Passed
Push — master ( 23853d...5334ba )
by Volodymyr
08:53
created

General::disableConfigPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright (c) 2019. Volodymyr Hryvinskyi.  All rights reserved.
4
 * @author: <mailto:[email protected]>
5
 * @github: <https://github.com/hryvinskyi>
6
 */
7
8
declare(strict_types=1);
9
10
namespace Hryvinskyi\InvisibleCaptcha\Helper\Config;
11
12
use Hryvinskyi\InvisibleCaptcha\Helper\AbstractConfig;
13
use Magento\Store\Model\ScopeInterface;
14
15
/**
16
 * Class General
17
 */
18
class General extends AbstractConfig
19
{
20
    /**
21
     * Configuration path
22
     */
23
    const CONFIG_PATH_GENERAL_ENABLE_MODULE = 'hryvinskyi_invisible_captcha/general/enabledCaptcha';
24
    const CONFIG_PATH_GENERAL_SITE_KEY = 'hryvinskyi_invisible_captcha/general/captchaSiteKey';
25
    const CONFIG_PATH_GENERAL_SECRET_KEY = 'hryvinskyi_invisible_captcha/general/captchaSecretKey';
26
    const CONFIG_PATH_GENERAL_USE_LAZY_LOAD = 'hryvinskyi_invisible_captcha/general/useLazyLoad';
27
28
    /**
29
     * Is google recaptcha enable global
30
     *
31
     * @param string $scopeType
32
     * @param mixed $scopeCode
33
     *
34
     * @return bool
35
     */
36
    public function hasEnabled(
37
        string $scopeType = ScopeInterface::SCOPE_WEBSITES,
38
        $scopeCode = null
39
    ): bool {
40
        return $this->scopeConfig->isSetFlag(
41
            self::CONFIG_PATH_GENERAL_ENABLE_MODULE,
42
            $scopeType,
43
            $scopeCode
44
        );
45
    }
46
47
    /**
48
     * Return Captcha Key
49
     *
50
     * @param string $scopeType
51
     * @param mixed $scopeCode
52
     *
53
     * @return string
54
     */
55
    public function getSiteKey(
56
        string $scopeType = ScopeInterface::SCOPE_WEBSITES,
57
        $scopeCode = null
58
    ): string {
59
        return $this->scopeConfig->getValue(
60
            self::CONFIG_PATH_GENERAL_SITE_KEY,
61
            $scopeType,
62
            $scopeCode
63
        );
64
    }
65
66
    /**
67
     * Return Secret Key
68
     *
69
     * @param string $scopeType
70
     * @param mixed $scopeCode
71
     *
72
     * @return string
73
     */
74
    public function getSecretKey(
75
        string $scopeType = ScopeInterface::SCOPE_WEBSITES,
76
        $scopeCode = null
77
    ): string {
78
        return $this->scopeConfig->getValue(
79
            self::CONFIG_PATH_GENERAL_SECRET_KEY,
80
            $scopeType,
81
            $scopeCode
82
        );
83
    }
84
85
    /**
86
     * Is google recaptcha load lazy
87
     *
88
     * @param string $scopeType
89
     * @param mixed $scopeCode
90
     *
91
     * @return bool
92
     */
93
    public function isLazyLoad(
94
        string $scopeType = ScopeInterface::SCOPE_WEBSITES,
95
        $scopeCode = null
96
    ): bool {
97
        return $this->scopeConfig->isSetFlag(
98
            self::CONFIG_PATH_GENERAL_USE_LAZY_LOAD,
99
            $scopeType,
100
            $scopeCode
101
        );
102
    }
103
104
    /**
105
     * Get config by path
106
     *
107
     * @param string $path
108
     * @param mixed $storeId
109
     * @param string $scope
110
     *
111
     * @return mixed
112
     */
113
    public function getConfigValueByPath(
114
        $path,
115
        $storeId = null,
116
        $scope = ScopeInterface::SCOPE_WEBSITES
117
    ) {
118
        return $this->scopeConfig->getValue($path, $scope, $storeId);
119
    }
120
121
    /**
122
     * Disable config path
123
     *
124
     * @return string
125
     */
126
    public function disableConfigPath(): string
127
    {
128
        return self::CONFIG_PATH_GENERAL_ENABLE_MODULE;
129
    }
130
}
131