Passed
Push — master ( 984fd7...e432c5 )
by Volodymyr
25:21 queued 07:29
created

General::isDisabledSubmitForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 8
rs 10
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
    const CONFIG_PATH_GENERAL_DISABLE_SUBMIT_FORM = 'hryvinskyi_invisible_captcha/general/disableSubmitForm';
28
    const CONFIG_PATH_GENERAL_DEBUG = 'hryvinskyi_invisible_captcha/general/debug';
29
30
    /**
31
     * Is google recaptcha enable global
32
     *
33
     * @param string $scopeType
34
     * @param mixed $scopeCode
35
     *
36
     * @return bool
37
     */
38
    public function hasEnabled(
39
        string $scopeType = ScopeInterface::SCOPE_WEBSITES,
40
        $scopeCode = null
41
    ): bool {
42
        return $this->scopeConfig->isSetFlag(
43
            self::CONFIG_PATH_GENERAL_ENABLE_MODULE,
44
            $scopeType,
45
            $scopeCode
46
        );
47
    }
48
49
    /**
50
     * Return Captcha Key
51
     *
52
     * @param string $scopeType
53
     * @param mixed $scopeCode
54
     *
55
     * @return string
56
     */
57
    public function getSiteKey(
58
        string $scopeType = ScopeInterface::SCOPE_WEBSITES,
59
        $scopeCode = null
60
    ): string {
61
        return $this->scopeConfig->getValue(
62
            self::CONFIG_PATH_GENERAL_SITE_KEY,
63
            $scopeType,
64
            $scopeCode
65
        );
66
    }
67
68
    /**
69
     * Return Secret Key
70
     *
71
     * @param string $scopeType
72
     * @param mixed $scopeCode
73
     *
74
     * @return string
75
     */
76
    public function getSecretKey(
77
        string $scopeType = ScopeInterface::SCOPE_WEBSITES,
78
        $scopeCode = null
79
    ): string {
80
        return $this->scopeConfig->getValue(
81
            self::CONFIG_PATH_GENERAL_SECRET_KEY,
82
            $scopeType,
83
            $scopeCode
84
        );
85
    }
86
87
    /**
88
     * Is google recaptcha load lazy
89
     *
90
     * @param string $scopeType
91
     * @param mixed $scopeCode
92
     *
93
     * @return bool
94
     */
95
    public function isLazyLoad(
96
        string $scopeType = ScopeInterface::SCOPE_WEBSITES,
97
        $scopeCode = null
98
    ): bool {
99
        return $this->scopeConfig->isSetFlag(
100
            self::CONFIG_PATH_GENERAL_USE_LAZY_LOAD,
101
            $scopeType,
102
            $scopeCode
103
        );
104
    }
105
106
    /**
107
     * Is google recaptcha load lazy
108
     *
109
     * @param string $scopeType
110
     * @param mixed $scopeCode
111
     *
112
     * @return bool
113
     */
114
    public function isDisabledSubmitForm(
115
        string $scopeType = ScopeInterface::SCOPE_WEBSITES,
116
        $scopeCode = null
117
    ): bool {
118
        return $this->scopeConfig->isSetFlag(
119
            self::CONFIG_PATH_GENERAL_DISABLE_SUBMIT_FORM,
120
            $scopeType,
121
            $scopeCode
122
        );
123
    }
124
125
    /**
126
     * Is enabled debugging
127
     *
128
     * @return bool
129
     */
130
    public function isDebug(): bool
131
    {
132
        return $this->scopeConfig->isSetFlag(self::CONFIG_PATH_GENERAL_DEBUG);
133
    }
134
135
    /**
136
     * Get config by path
137
     *
138
     * @param string $path
139
     * @param mixed $storeId
140
     * @param string $scope
141
     *
142
     * @return mixed
143
     */
144
    public function getConfigValueByPath(
145
        $path,
146
        $storeId = null,
147
        $scope = ScopeInterface::SCOPE_WEBSITES
148
    ) {
149
        return $this->scopeConfig->getValue($path, $scope, $storeId);
150
    }
151
152
    /**
153
     * Disable config path
154
     *
155
     * @return string
156
     */
157
    public function disableConfigPath(): string
158
    {
159
        return self::CONFIG_PATH_GENERAL_ENABLE_MODULE;
160
    }
161
}
162