Passed
Branch master (fbf0a6)
by Volodymyr
04:04
created

Frontend::hasEnabled()   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
nc 1
nop 2
dl 0
loc 8
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 Magento\Framework\App\Helper\AbstractHelper;
13
use Magento\Store\Model\ScopeInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Store\Model\ScopeInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
15
/**
16
 * Class Frontend
17
 */
18
class Frontend extends AbstractHelper
19
{
20
    /**
21
     * Configuration path
22
     */
23
    const CONFIG_PATH_FRONTEND_ENABLED = 'hryvinskyi_invisible_captcha/frontend/enabled';
24
    const CONFIG_PATH_FRONTEND_ENABLED_CUSTOMER_LOGIN = 'hryvinskyi_invisible_captcha/frontend/enabledCustomerLogin';
25
    const CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CUSTOMER_LOGIN = 'hryvinskyi_invisible_captcha/frontend/scoreThresholdCustomerLogin';
26
    const CONFIG_PATH_FRONTEND_ENABLED_CUSTOMER_CREATE = 'hryvinskyi_invisible_captcha/frontend/enabledCustomerCreate';
27
    const CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CUSTOMER_CREATE = 'hryvinskyi_invisible_captcha/frontend/scoreThresholdCustomerCreate';
28
    const CONFIG_PATH_FRONTEND_ENABLED_CUSTOMER_FORGOT = 'hryvinskyi_invisible_captcha/frontend/enabledCustomerForgot';
29
    const CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CUSTOMER_FORGOT = 'hryvinskyi_invisible_captcha/frontend/scoreThresholdCustomerForgot';
30
    const CONFIG_PATH_FRONTEND_ENABLED_CONTACT = 'hryvinskyi_invisible_captcha/frontend/enabledContact';
31
    const CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CONTACT = 'hryvinskyi_invisible_captcha/frontend/scoreThresholdContact';
32
    const CONFIG_PATH_FRONTEND_ENABLED_NEWSLETTER = 'hryvinskyi_invisible_captcha/frontend/enabledNewsletter';
33
    const CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_NEWSLETTER = 'hryvinskyi_invisible_captcha/frontend/scoreThresholdNewsletter';
34
35
    /**
36
     * Is google recaptcha enable global
37
     *
38
     * @param string $scopeType
39
     * @param mixed $scopeCode
40
     *
41
     * @return bool
42
     */
43
    public function hasEnabled(
44
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
45
        $scopeCode = null
46
    ): bool {
47
        return $this->scopeConfig->isSetFlag(
48
            self::CONFIG_PATH_FRONTEND_ENABLED,
49
            $scopeType,
50
            $scopeCode
51
        );
52
    }
53
54
    /**
55
     * Is google recaptcha enable customer login
56
     *
57
     * @param string $scopeType
58
     * @param mixed $scopeCode
59
     *
60
     * @return bool
61
     */
62
    public function hasEnabledCustomerLogin(
63
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
64
        $scopeCode = null
65
    ): bool {
66
        return $this->scopeConfig->isSetFlag(
67
            self::CONFIG_PATH_FRONTEND_ENABLED_CUSTOMER_LOGIN,
68
            $scopeType,
69
            $scopeCode
70
        );
71
    }
72
73
    /**
74
     * Get google recaptcha score threshold login
75
     *
76
     * @param string $scopeType
77
     * @param mixed $scopeCode
78
     *
79
     * @return float
80
     */
81
    public function getScoreThresholdCustomerLogin(
82
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
83
        $scopeCode = null
84
    ): float {
85
        return (float)$this->scopeConfig->getValue(
86
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CUSTOMER_LOGIN,
87
            $scopeType,
88
            $scopeCode
89
        );
90
    }
91
92
    /**
93
     * Is google recaptcha enable customer create
94
     *
95
     * @param string $scopeType
96
     * @param mixed $scopeCode
97
     *
98
     * @return bool
99
     */
100
    public function hasEnabledCustomerCreate(
101
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
102
        $scopeCode = null
103
    ): bool {
104
        return $this->scopeConfig->isSetFlag(
105
            self::CONFIG_PATH_FRONTEND_ENABLED_CUSTOMER_CREATE,
106
            $scopeType,
107
            $scopeCode
108
        );
109
    }
110
111
    /**
112
     * Get google recaptcha score threshold customer create
113
     *
114
     * @param string $scopeType
115
     * @param mixed $scopeCode
116
     *
117
     * @return float
118
     */
119
    public function getScoreThresholdCustomerCreate(
120
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
121
        $scopeCode = null
122
    ): float {
123
        return (float)$this->scopeConfig->getValue(
124
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CUSTOMER_CREATE,
125
            $scopeType,
126
            $scopeCode
127
        );
128
    }
129
130
    /**
131
     * Is google recaptcha enable customer forgot
132
     *
133
     * @param string $scopeType
134
     * @param mixed $scopeCode
135
     *
136
     * @return bool
137
     */
138
    public function hasEnabledCustomerForgot(
139
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
140
        $scopeCode = null
141
    ): bool {
142
        return $this->scopeConfig->isSetFlag(
143
            self::CONFIG_PATH_FRONTEND_ENABLED_CUSTOMER_FORGOT,
144
            $scopeType,
145
            $scopeCode
146
        );
147
    }
148
149
    /**
150
     * Get google recaptcha score threshold customer forgot
151
     *
152
     * @param string $scopeType
153
     * @param mixed $scopeCode
154
     *
155
     * @return float
156
     */
157
    public function getScoreThresholdCustomerForgot(
158
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
159
        $scopeCode = null
160
    ): float {
161
        return (float)$this->scopeConfig->getValue(
162
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CUSTOMER_FORGOT,
163
            $scopeType,
164
            $scopeCode
165
        );
166
    }
167
168
    /**
169
     * Is google recaptcha enable contact
170
     *
171
     * @param string $scopeType
172
     * @param mixed $scopeCode
173
     *
174
     * @return bool
175
     */
176
    public function hasEnabledContact(
177
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
178
        $scopeCode = null
179
    ): bool {
180
        return $this->scopeConfig->isSetFlag(
181
            self::CONFIG_PATH_FRONTEND_ENABLED_CONTACT,
182
            $scopeType,
183
            $scopeCode
184
        );
185
    }
186
187
    /**
188
     * Get google recaptcha score threshold contact
189
     *
190
     * @param string $scopeType
191
     * @param mixed $scopeCode
192
     *
193
     * @return float
194
     */
195
    public function getScoreThresholdContact(
196
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
197
        $scopeCode = null
198
    ): float {
199
        return (float)$this->scopeConfig->getValue(
200
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CONTACT,
201
            $scopeType,
202
            $scopeCode
203
        );
204
    }
205
206
    /**
207
     * Is google recaptcha enable newsletter
208
     *
209
     * @param string $scopeType
210
     * @param mixed $scopeCode
211
     *
212
     * @return bool
213
     */
214
    public function hasEnabledNewsletter(
215
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
216
        $scopeCode = null
217
    ): bool {
218
        return $this->scopeConfig->isSetFlag(
219
            self::CONFIG_PATH_FRONTEND_ENABLED_NEWSLETTER,
220
            $scopeType,
221
            $scopeCode
222
        );
223
    }
224
225
    /**
226
     * Get google recaptcha score threshold newsletter
227
     *
228
     * @param string $scopeType
229
     * @param mixed $scopeCode
230
     *
231
     * @return float
232
     */
233
    public function getScoreThresholdNewsletter(
234
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
235
        $scopeCode = null
236
    ): float {
237
        return (float)$this->scopeConfig->getValue(
238
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_NEWSLETTER,
239
            $scopeType,
240
            $scopeCode
241
        );
242
    }
243
}
244