Passed
Push — master ( 7b08a2...148763 )
by Володимир
05:46
created

Frontend::hasEnabledSendFriend()   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 Magento\Framework\App\Helper\AbstractHelper;
13
use Magento\Store\Model\ScopeInterface;
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
    const CONFIG_PATH_FRONTEND_ENABLED_SENDFRIEND = 'hryvinskyi_invisible_captcha/frontend/enabledSendFriend';
35
    const CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_SENDFRIEND = 'hryvinskyi_invisible_captcha/frontend/scoreThresholdSendFriend';
36
37
    /**
38
     * Is google recaptcha enable global
39
     *
40
     * @param string $scopeType
41
     * @param mixed $scopeCode
42
     *
43
     * @return bool
44
     */
45
    public function hasEnabled(
46
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
47
        $scopeCode = null
48
    ): bool {
49
        return $this->scopeConfig->isSetFlag(
50
            self::CONFIG_PATH_FRONTEND_ENABLED,
51
            $scopeType,
52
            $scopeCode
53
        );
54
    }
55
56
    /**
57
     * Is google recaptcha enable customer login
58
     *
59
     * @param string $scopeType
60
     * @param mixed $scopeCode
61
     *
62
     * @return bool
63
     */
64
    public function hasEnabledCustomerLogin(
65
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
66
        $scopeCode = null
67
    ): bool {
68
        return $this->scopeConfig->isSetFlag(
69
            self::CONFIG_PATH_FRONTEND_ENABLED_CUSTOMER_LOGIN,
70
            $scopeType,
71
            $scopeCode
72
        );
73
    }
74
75
    /**
76
     * Get google recaptcha score threshold login
77
     *
78
     * @param string $scopeType
79
     * @param mixed $scopeCode
80
     *
81
     * @return float
82
     */
83
    public function getScoreThresholdCustomerLogin(
84
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
85
        $scopeCode = null
86
    ): float {
87
        return (float)$this->scopeConfig->getValue(
88
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CUSTOMER_LOGIN,
89
            $scopeType,
90
            $scopeCode
91
        );
92
    }
93
94
    /**
95
     * Is google recaptcha enable customer create
96
     *
97
     * @param string $scopeType
98
     * @param mixed $scopeCode
99
     *
100
     * @return bool
101
     */
102
    public function hasEnabledCustomerCreate(
103
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
104
        $scopeCode = null
105
    ): bool {
106
        return $this->scopeConfig->isSetFlag(
107
            self::CONFIG_PATH_FRONTEND_ENABLED_CUSTOMER_CREATE,
108
            $scopeType,
109
            $scopeCode
110
        );
111
    }
112
113
    /**
114
     * Get google recaptcha score threshold customer create
115
     *
116
     * @param string $scopeType
117
     * @param mixed $scopeCode
118
     *
119
     * @return float
120
     */
121
    public function getScoreThresholdCustomerCreate(
122
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
123
        $scopeCode = null
124
    ): float {
125
        return (float)$this->scopeConfig->getValue(
126
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CUSTOMER_CREATE,
127
            $scopeType,
128
            $scopeCode
129
        );
130
    }
131
132
    /**
133
     * Is google recaptcha enable customer forgot
134
     *
135
     * @param string $scopeType
136
     * @param mixed $scopeCode
137
     *
138
     * @return bool
139
     */
140
    public function hasEnabledCustomerForgot(
141
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
142
        $scopeCode = null
143
    ): bool {
144
        return $this->scopeConfig->isSetFlag(
145
            self::CONFIG_PATH_FRONTEND_ENABLED_CUSTOMER_FORGOT,
146
            $scopeType,
147
            $scopeCode
148
        );
149
    }
150
151
    /**
152
     * Get google recaptcha score threshold customer forgot
153
     *
154
     * @param string $scopeType
155
     * @param mixed $scopeCode
156
     *
157
     * @return float
158
     */
159
    public function getScoreThresholdCustomerForgot(
160
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
161
        $scopeCode = null
162
    ): float {
163
        return (float)$this->scopeConfig->getValue(
164
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CUSTOMER_FORGOT,
165
            $scopeType,
166
            $scopeCode
167
        );
168
    }
169
170
    /**
171
     * Is google recaptcha enable contact
172
     *
173
     * @param string $scopeType
174
     * @param mixed $scopeCode
175
     *
176
     * @return bool
177
     */
178
    public function hasEnabledContact(
179
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
180
        $scopeCode = null
181
    ): bool {
182
        return $this->scopeConfig->isSetFlag(
183
            self::CONFIG_PATH_FRONTEND_ENABLED_CONTACT,
184
            $scopeType,
185
            $scopeCode
186
        );
187
    }
188
189
    /**
190
     * Get google recaptcha score threshold contact
191
     *
192
     * @param string $scopeType
193
     * @param mixed $scopeCode
194
     *
195
     * @return float
196
     */
197
    public function getScoreThresholdContact(
198
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
199
        $scopeCode = null
200
    ): float {
201
        return (float)$this->scopeConfig->getValue(
202
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_CONTACT,
203
            $scopeType,
204
            $scopeCode
205
        );
206
    }
207
208
    /**
209
     * Is google recaptcha enable newsletter
210
     *
211
     * @param string $scopeType
212
     * @param mixed $scopeCode
213
     *
214
     * @return bool
215
     */
216
    public function hasEnabledNewsletter(
217
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
218
        $scopeCode = null
219
    ): bool {
220
        return $this->scopeConfig->isSetFlag(
221
            self::CONFIG_PATH_FRONTEND_ENABLED_NEWSLETTER,
222
            $scopeType,
223
            $scopeCode
224
        );
225
    }
226
227
    /**
228
     * Get google recaptcha score threshold newsletter
229
     *
230
     * @param string $scopeType
231
     * @param mixed $scopeCode
232
     *
233
     * @return float
234
     */
235
    public function getScoreThresholdNewsletter(
236
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
237
        $scopeCode = null
238
    ): float {
239
        return (float)$this->scopeConfig->getValue(
240
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_NEWSLETTER,
241
            $scopeType,
242
            $scopeCode
243
        );
244
    }
245
246
    /**
247
     * Is google recaptcha enable send to friend
248
     *
249
     * @param string $scopeType
250
     * @param mixed $scopeCode
251
     *
252
     * @return bool
253
     */
254
    public function hasEnabledSendFriend(
255
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
256
        $scopeCode = null
257
    ): bool {
258
        return $this->scopeConfig->isSetFlag(
259
            self::CONFIG_PATH_FRONTEND_ENABLED_SENDFRIEND,
260
            $scopeType,
261
            $scopeCode
262
        );
263
    }
264
265
    /**
266
     * Get google recaptcha score threshold send to friend
267
     *
268
     * @param string $scopeType
269
     * @param mixed $scopeCode
270
     *
271
     * @return float
272
     */
273
    public function getScoreThresholdSendFriend(
274
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
275
        $scopeCode = null
276
    ): float {
277
        return (float)$this->scopeConfig->getValue(
278
            self::CONFIG_PATH_FRONTEND_SCORE_THRESHOLD_SENDFRIEND,
279
            $scopeType,
280
            $scopeCode
281
        );
282
    }
283
}
284