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.

Studioforty9_Recaptcha_Helper_Data   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 142
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 14
lcom 1
cbo 0
dl 0
loc 142
rs 10
c 0
b 0
f 0

10 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 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
    /**#@-*/
36
37
    /**
38
     * Is the module enabled in configuration.
39
     *
40
     * @codeCoverageIgnore
41
     * @return bool
42
     */
43
    public function isEnabled()
44
    {
45
        return Mage::getStoreConfigFlag(self::MODULE_ENABLED);
46
    }
47
48
    /**
49
     * The recaptcha site key.
50
     *
51
     * @codeCoverageIgnore
52
     * @return string
53
     */
54
    public function getSiteKey()
55
    {
56
        return Mage::getStoreConfig(self::MODULE_KEY_SITE);
57
    }
58
59
    /**
60
     * The recaptcha secret key.
61
     *
62
     * @codeCoverageIgnore
63
     * @return string
64
     */
65
    public function getSecretKey()
66
    {
67
        return Mage::getStoreConfig(self::MODULE_KEY_SECRET);
68
    }
69
70
    /**
71
     * The recaptcha widget theme.
72
     *
73
     * @codeCoverageIgnore
74
     * @return string
75
     */
76
    public function getTheme()
77
    {
78
        return Mage::getStoreConfig(self::MODULE_KEY_THEME);
79
    }
80
81
    /**
82
     * The recaptcha widget type.
83
     *
84
     * @codeCoverageIgnore
85
     * @return string
86
     */
87
    public function getType()
88
    {
89
        return Mage::getStoreConfig(self::MODULE_KEY_TYPE);
90
    }
91
92
    /**
93
     * The recaptcha widget size.
94
     *
95
     * @codeCoverageIgnore
96
     * @return string
97
     */
98
    public function getSize()
99
    {
100
        return Mage::getStoreConfig(self::MODULE_KEY_SIZE);
101
    }
102
103
    /**
104
     * The enabled routes.
105
     *
106
     * @codeCoverageIgnore
107
     * @return string
108
     */
109
    public function getEnabledRoutes()
110
    {
111
        $routes = array_filter(explode(',', Mage::getStoreConfig(self::MODULE_KEY_ROUTES)));
112
        array_map('strtolower', $routes);
113
        
114
        return $routes;
115
    }
116
117
    /**
118
     * Is the provided route enabled.
119
     *
120
     * @codeCoverageIgnore
121
     * @param string $route
122
     * @return bool
123
     */
124
    public function isEnabledRoute($route)
125
    {
126
        foreach ($this->getEnabledRoutes() as $enabledRoute) {
127
            if (false !== strpos($route, $enabledRoute)) {
128
                return true;
129
            }
130
        }
131
132
        return false;
133
    }
134
135
    /**
136
     * Is the module allowed to run.
137
     *
138
     * @codeCoverageIgnore
139
     * @param string $route
140
     * @return bool
141
     */
142
    public function isAllowed($route)
143
    {
144
        if (! $this->isModuleActive() || ! $this->isEnabled()) {
145
            return false;
146
        }
147
        
148
        return $this->isEnabledRoute($route);
149
    }
150
		
151
    /**
152
     * Is the module active.
153
     *
154
     * @codeCoverageIgnore
155
     * @return bool
156
     */
157
    public function isModuleActive()
158
    {
159
        return Mage::getConfig()
160
            ->getModuleConfig("Studioforty9_Recaptcha")
161
            ->is('active', 'true');
162
    }
163
}
164