| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 107 | public function rules(): array |
||
| 108 | { |
||
| 109 | return [ |
||
| 110 | ['id', 'integer'], |
||
| 111 | ['siteId', 'integer'], |
||
| 112 | ['siteId', 'default', 'value' => null], |
||
| 113 | ['associatedElementId', 'default', 'value' => 0], |
||
| 114 | ['associatedElementId', 'integer'], |
||
| 115 | ['enabled', 'boolean'], |
||
| 116 | ['redirectSrcMatch', 'string'], |
||
| 117 | ['redirectSrcMatch', 'in', 'range' => ['pathonly', 'fullurl']], |
||
| 118 | ['redirectSrcMatch', 'default', 'value' => 'pathonly'], |
||
| 119 | ['redirectSrcMatch', DbStringValidator::class, 'max' => 32], |
||
| 120 | ['redirectMatchType', 'string'], |
||
| 121 | ['redirectMatchType', 'in', 'range' => ['exactmatch', 'regexmatch']], |
||
| 122 | ['redirectMatchType', 'default', 'value' => 'exactmatch'], |
||
| 123 | ['redirectMatchType', DbStringValidator::class, 'max' => 32], |
||
| 124 | [ |
||
| 125 | [ |
||
| 126 | 'redirectSrcUrl', |
||
| 127 | 'redirectSrcUrlParsed', |
||
| 128 | 'redirectDestUrl', |
||
| 129 | ], |
||
| 130 | 'default', |
||
| 131 | 'value' => '', |
||
| 132 | ], |
||
| 133 | ['redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl'], |
||
| 134 | [ |
||
| 135 | [ |
||
| 136 | 'redirectSrcUrl', |
||
| 137 | 'redirectSrcUrlParsed', |
||
| 138 | 'redirectDestUrl', |
||
| 139 | ], |
||
| 140 | UriValidator::class, |
||
| 141 | ], |
||
| 142 | [ |
||
| 143 | [ |
||
| 144 | 'redirectSrcUrl', |
||
| 145 | 'redirectSrcUrlParsed', |
||
| 146 | 'redirectMatchType', |
||
| 147 | 'redirectDestUrl', |
||
| 148 | ], |
||
| 149 | DbStringValidator::class, |
||
| 150 | 'max' => 255, |
||
| 151 | ], |
||
| 152 | [ |
||
| 153 | [ |
||
| 154 | 'redirectSrcUrl', |
||
| 155 | 'redirectSrcUrlParsed', |
||
| 156 | 'redirectDestUrl', |
||
| 157 | ], |
||
| 158 | 'string', |
||
| 159 | ], |
||
| 160 | ['redirectHttpCode', 'integer'], |
||
| 161 | ['redirectHttpCode', 'default', 'value' => 301], |
||
| 162 | ['redirectHttpCode', 'in', 'range' => [301, 302, 307, 308, 410]], |
||
| 163 | ['hitCount', 'default', 'value' => 0], |
||
| 164 | ['hitCount', 'integer'], |
||
| 165 | ['hitLastTime', 'safe'], |
||
| 166 | ]; |
||
| 182 |