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

General   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 81
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigValueByPath() 0 6 1
A hasEnabled() 0 8 1
A getSiteKey() 0 8 1
A getSecretKey() 0 8 1
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 General
17
 */
18
class General extends AbstractHelper
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
27
    /**
28
     * Is google recaptcha enable global
29
     *
30
     * @param string $scopeType
31
     * @param mixed $scopeCode
32
     *
33
     * @return bool
34
     */
35
    public function hasEnabled(
36
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
37
        $scopeCode = null
38
    ): bool {
39
        return $this->scopeConfig->isSetFlag(
40
            self::CONFIG_PATH_GENERAL_ENABLE_MODULE,
41
            $scopeType,
42
            $scopeCode
43
        );
44
    }
45
46
    /**
47
     * Return Captcha Key
48
     *
49
     * @param string $scopeType
50
     * @param mixed $scopeCode
51
     *
52
     * @return string
53
     */
54
    public function getSiteKey(
55
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
56
        $scopeCode = null
57
    ): string {
58
        return $this->scopeConfig->getValue(
59
            self::CONFIG_PATH_GENERAL_SITE_KEY,
60
            $scopeType,
61
            $scopeCode
62
        );
63
    }
64
65
    /**
66
     * Return Secret Key
67
     *
68
     * @param string $scopeType
69
     * @param mixed $scopeCode
70
     *
71
     * @return string
72
     */
73
    public function getSecretKey(
74
        string $scopeType = ScopeInterface::SCOPE_WEBSITE,
75
        $scopeCode = null
76
    ): string {
77
        return $this->scopeConfig->getValue(
78
            self::CONFIG_PATH_GENERAL_SECRET_KEY,
79
            $scopeType,
80
            $scopeCode
81
        );
82
    }
83
84
    /**
85
     * Get config by path
86
     *
87
     * @param $path
88
     * @param null $storeId
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $storeId is correct as it would always require null to be passed?
Loading history...
89
     * @param string $scope
90
     *
91
     * @return mixed
92
     */
93
    public function getConfigValueByPath(
94
        $path,
95
        $storeId = null,
96
        $scope = ScopeInterface::SCOPE_WEBSITE
97
    ) {
98
        return $this->scopeConfig->getValue($path, $scope, $storeId);
99
    }
100
}
101