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