GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#31)
by
unknown
19:16 queued 04:19
created

Studioforty9_Recaptcha_Helper_Data   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 166
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 16
lcom 1
cbo 0
dl 0
loc 166
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A isEnabled() 0 4 1
A getSiteKey() 0 4 1
A getSecretKey() 0 4 1
A getTheme() 0 4 1
A getType() 0 4 1
A getButtonsSelector() 0 4 1
A isInvisible() 0 4 1
A getSize() 0 4 1
A getEnabledRoutes() 0 7 1
A isEnabledRoute() 0 10 3
A isAllowed() 0 8 3
A isModuleActive() 0 6 1
1
<?php
2
/**
3
 * Studioforty9_Recaptcha
4
 *
5
 * @category  Studioforty9
6
 * @package   Studioforty9_Recaptcha
7
 * @author    StudioForty9 <[email protected]>
8
 * @copyright 2015 StudioForty9 (http://www.studioforty9.com)
9
 * @license   https://github.com/studioforty9/recaptcha/blob/master/LICENCE BSD
10
 * @version   1.5.7
11
 * @link      https://github.com/studioforty9/recaptcha
12
 */
13
14
/**
15
 * Studioforty9_Recaptcha_Helper_Data
16
 *
17
 * @category   Studioforty9
18
 * @package    Studioforty9_Recaptcha
19
 * @subpackage Helper
20
 * @author     StudioForty9 <[email protected]>
21
 */
22
class Studioforty9_Recaptcha_Helper_Data extends Mage_Core_Helper_Abstract
23
{
24
    /**#@+
25
     * Configuration paths.
26
     * @var string
27
     */
28
    const MODULE_ENABLED = 'google/recaptcha/enabled';
29
    const MODULE_KEY_SITE = 'google/recaptcha/site_key';
30
    const MODULE_KEY_SECRET = 'google/recaptcha/secret_key';
31
    const MODULE_KEY_THEME = 'google/recaptcha/theme';
32
    const MODULE_KEY_SIZE = 'google/recaptcha/size';
33
    const MODULE_KEY_TYPE = 'google/recaptcha/type';
34
    const MODULE_KEY_ROUTES = 'google/recaptcha/enabled_routes';
35
    const MODULE_INVISIBLE = 'google/recaptcha/invisible';
36
    const MODULE_BUTTONS_SELECTOR = 'google/recaptcha/buttons_selectors';
37
    /**#@-*/
38
39
    /**
40
     * Is the module enabled in configuration.
41
     *
42
     * @codeCoverageIgnore
43
     * @return bool
44
     */
45
    public function isEnabled()
46
    {
47
        return Mage::getStoreConfigFlag(self::MODULE_ENABLED);
48
    }
49
50
    /**
51
     * The recaptcha site key.
52
     *
53
     * @codeCoverageIgnore
54
     * @return string
55
     */
56
    public function getSiteKey()
57
    {
58
        return Mage::getStoreConfig(self::MODULE_KEY_SITE);
59
    }
60
61
    /**
62
     * The recaptcha secret key.
63
     *
64
     * @codeCoverageIgnore
65
     * @return string
66
     */
67
    public function getSecretKey()
68
    {
69
        return Mage::getStoreConfig(self::MODULE_KEY_SECRET);
70
    }
71
72
    /**
73
     * The recaptcha widget theme.
74
     *
75
     * @codeCoverageIgnore
76
     * @return string
77
     */
78
    public function getTheme()
79
    {
80
        return Mage::getStoreConfig(self::MODULE_KEY_THEME);
81
    }
82
83
    /**
84
     * The recaptcha widget type.
85
     *
86
     * @codeCoverageIgnore
87
     * @return string
88
     */
89
    public function getType()
90
    {
91
        return Mage::getStoreConfig(self::MODULE_KEY_TYPE);
92
    }
93
94
    /**
95
     * The recaptcha widget buttons selector.
96
     *
97
     * @codeCoverageIgnore
98
     * @return string
99
     */
100
    public function getButtonsSelector()
101
    {
102
        return Mage::getStoreConfig(self::MODULE_BUTTONS_SELECTOR);
103
    }
104
105
    /**
106
     * The recaptcha widget invisible.
107
     *
108
     * @codeCoverageIgnore
109
     * @return string
110
     */
111
    public function isInvisible()
112
    {
113
        return Mage::getStoreConfigFlag(self::MODULE_INVISIBLE);
114
    }
115
116
    /**
117
     * The recaptcha widget size.
118
     *
119
     * @codeCoverageIgnore
120
     * @return string
121
     */
122
    public function getSize()
123
    {
124
        return Mage::getStoreConfig(self::MODULE_KEY_SIZE);
125
    }
126
127
    /**
128
     * The enabled routes.
129
     *
130
     * @codeCoverageIgnore
131
     * @return string
132
     */
133
    public function getEnabledRoutes()
134
    {
135
        $routes = array_filter(explode(',', Mage::getStoreConfig(self::MODULE_KEY_ROUTES)));
136
        array_map('strtolower', $routes);
137
        
138
        return $routes;
139
    }
140
141
    /**
142
     * Is the provided route enabled.
143
     *
144
     * @codeCoverageIgnore
145
     * @param string $route
146
     * @return bool
147
     */
148
    public function isEnabledRoute($route)
149
    {
150
        foreach ($this->getEnabledRoutes() as $enabledRoute) {
151
            if (false !== strpos($route, $enabledRoute)) {
152
                return true;
153
            }
154
        }
155
156
        return false;
157
    }
158
159
    /**
160
     * Is the module allowed to run.
161
     *
162
     * @codeCoverageIgnore
163
     * @param string $route
164
     * @return bool
165
     */
166
    public function isAllowed($route)
167
    {
168
        if (! $this->isModuleActive() || ! $this->isEnabled()) {
169
            return false;
170
        }
171
        
172
        return $this->isEnabledRoute($route);
173
    }
174
		
175
    /**
176
     * Is the module active.
177
     *
178
     * @codeCoverageIgnore
179
     * @return bool
180
     */
181
    public function isModuleActive()
182
    {
183
        return Mage::getConfig()
184
            ->getModuleConfig("Studioforty9_Recaptcha")
185
            ->is('active', 'true');
186
    }
187
}
188