| Conditions | 11 |
| Paths | 7 |
| Total Lines | 33 |
| Code Lines | 16 |
| Lines | 33 |
| Ratio | 100 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 106 | View Code Duplication | public function FilterAjaxResponse($sAction, &$aResponseItem) |
|
| 107 | { |
||
| 108 | if ('Login' === $sAction && $aResponseItem && isset($aResponseItem['Result'])) |
||
| 109 | { |
||
| 110 | $oCacher = $this->Manager()->Actions()->Cacher(); |
||
| 111 | $iConfigLimit = (int) $this->Config()->Get('plugin', 'error_limit', 0); |
||
| 112 | $sKey = $this->getCaptchaCacherKey(); |
||
| 113 | |||
| 114 | if (0 < $iConfigLimit && $oCacher && $oCacher->IsInited()) |
||
| 115 | { |
||
| 116 | if (false === $aResponseItem['Result']) |
||
| 117 | { |
||
| 118 | $iLimit = 0; |
||
| 119 | $sLimut = $oCacher->Get($sKey); |
||
| 120 | if (0 < strlen($sLimut) && is_numeric($sLimut)) |
||
| 121 | { |
||
| 122 | $iLimit = (int) $sLimut; |
||
| 123 | } |
||
| 124 | |||
| 125 | $oCacher->Set($sKey, ++$iLimit); |
||
| 126 | |||
| 127 | if ($iConfigLimit <= $iLimit) |
||
| 128 | { |
||
| 129 | $aResponseItem['Captcha'] = true; |
||
| 130 | } |
||
| 131 | } |
||
| 132 | else |
||
| 133 | { |
||
| 134 | $oCacher->Delete($sKey); |
||
| 135 | } |
||
| 136 | } |
||
| 137 | } |
||
| 138 | } |
||
| 139 | } |
||
| 140 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.