| Conditions | 10 |
| Paths | 16 |
| Total Lines | 36 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 96 | protected function cleanAndPredictErrorParameters() |
||
| 97 | { |
||
| 98 | if (empty($this->optiTemplate->parametersErrorFromHydrate)) { |
||
| 99 | return; |
||
| 100 | } |
||
| 101 | $allParamsAndAlias = $this->optiTemplate->getParamsAndAlias(); |
||
| 102 | |||
| 103 | foreach ($this->optiTemplate->parametersErrorFromHydrate as $name => $value) { |
||
| 104 | if (!is_string($name)) { |
||
| 105 | // example : 1 => "ouvrage collectif" from |ouvrage collectif| |
||
| 106 | continue; |
||
| 107 | } |
||
| 108 | |||
| 109 | // delete error parameter if no value |
||
| 110 | if (empty($value)) { |
||
| 111 | unset($this->optiTemplate->parametersErrorFromHydrate[$name]); |
||
| 112 | |||
| 113 | continue; |
||
| 114 | } |
||
| 115 | |||
| 116 | $maxDistance = 1; |
||
| 117 | if (mb_strlen($name) >= 4) { |
||
| 118 | $maxDistance = 2; |
||
| 119 | } |
||
| 120 | if (mb_strlen($name) >= 8) { |
||
| 121 | $maxDistance = 3; |
||
| 122 | } |
||
| 123 | |||
| 124 | $predName = TextUtil::predictCorrectParam($name, $allParamsAndAlias, $maxDistance); |
||
| 125 | if ($predName && mb_strlen($name) >= 5) { |
||
| 126 | if (empty($this->getParam($predName))) { |
||
| 127 | $predName = $this->optiTemplate->getAliasParam($predName); |
||
| 128 | $this->setParam($predName, $value); |
||
| 129 | $this->addSummaryLog(sprintf('%s⇒%s ?', $name, $predName)); |
||
| 130 | $this->notCosmetic = true; |
||
|
|
|||
| 131 | unset($this->optiTemplate->parametersErrorFromHydrate[$name]); |
||
| 132 | } |
||
| 137 |