Conditions | 1 |
Paths | 1 |
Total Lines | 198 |
Code Lines | 143 |
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 |
||
116 | public function providerForTestGetPermissionsCriterion() |
||
117 | { |
||
118 | $criterionMock = $this |
||
119 | ->getMockBuilder('eZ\\Publish\\API\\Repository\\Values\\Content\\Query\\Criterion') |
||
120 | ->disableOriginalConstructor() |
||
121 | ->getMock(); |
||
122 | $limitationMock = $this |
||
123 | ->getMockBuilder('eZ\\Publish\\API\\Repository\\Values\\User\\Limitation') |
||
124 | ->getMockForAbstractClass(); |
||
125 | $limitationMock |
||
126 | ->expects($this->any()) |
||
127 | ->method('getIdentifier') |
||
128 | ->will($this->returnValue('limitationIdentifier')); |
||
129 | |||
130 | $policy1 = new Policy(array('limitations' => array($limitationMock))); |
||
131 | $policy2 = new Policy(array('limitations' => array($limitationMock, $limitationMock))); |
||
132 | |||
133 | return array( |
||
134 | array( |
||
135 | $criterionMock, |
||
136 | 1, |
||
137 | array( |
||
138 | array( |
||
139 | 'limitation' => null, |
||
140 | 'policies' => array($policy1), |
||
141 | ), |
||
142 | ), |
||
143 | $criterionMock, |
||
144 | ), |
||
145 | array( |
||
146 | $criterionMock, |
||
147 | 2, |
||
148 | array( |
||
149 | array( |
||
150 | 'limitation' => null, |
||
151 | 'policies' => array($policy1, $policy1), |
||
152 | ), |
||
153 | ), |
||
154 | new Criterion\LogicalOr(array($criterionMock, $criterionMock)), |
||
155 | ), |
||
156 | array( |
||
157 | $criterionMock, |
||
158 | 1, |
||
159 | array( |
||
160 | array( |
||
161 | 'limitation' => null, |
||
162 | 'policies' => array(new Policy(array('limitations' => '*')), $policy1), |
||
163 | ), |
||
164 | ), |
||
165 | $criterionMock, |
||
166 | ), |
||
167 | array( |
||
168 | $criterionMock, |
||
169 | 1, |
||
170 | array( |
||
171 | array( |
||
172 | 'limitation' => null, |
||
173 | 'policies' => array(new Policy(array('limitations' => array())), $policy1), |
||
174 | ), |
||
175 | ), |
||
176 | $criterionMock, |
||
177 | ), |
||
178 | array( |
||
179 | $criterionMock, |
||
180 | 2, |
||
181 | array( |
||
182 | array( |
||
183 | 'limitation' => null, |
||
184 | 'policies' => array($policy2), |
||
185 | ), |
||
186 | ), |
||
187 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
188 | ), |
||
189 | array( |
||
190 | $criterionMock, |
||
191 | 3, |
||
192 | array( |
||
193 | array( |
||
194 | 'limitation' => null, |
||
195 | 'policies' => array($policy1, $policy2), |
||
196 | ), |
||
197 | ), |
||
198 | new Criterion\LogicalOr( |
||
199 | array( |
||
200 | $criterionMock, |
||
201 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
202 | ) |
||
203 | ), |
||
204 | ), |
||
205 | array( |
||
206 | $criterionMock, |
||
207 | 2, |
||
208 | array( |
||
209 | array( |
||
210 | 'limitation' => null, |
||
211 | 'policies' => array($policy1), |
||
212 | ), |
||
213 | array( |
||
214 | 'limitation' => null, |
||
215 | 'policies' => array($policy1), |
||
216 | ), |
||
217 | ), |
||
218 | new Criterion\LogicalOr(array($criterionMock, $criterionMock)), |
||
219 | ), |
||
220 | array( |
||
221 | $criterionMock, |
||
222 | 3, |
||
223 | array( |
||
224 | array( |
||
225 | 'limitation' => null, |
||
226 | 'policies' => array($policy1), |
||
227 | ), |
||
228 | array( |
||
229 | 'limitation' => null, |
||
230 | 'policies' => array($policy1, $policy1), |
||
231 | ), |
||
232 | ), |
||
233 | new Criterion\LogicalOr(array($criterionMock, $criterionMock, $criterionMock)), |
||
234 | ), |
||
235 | array( |
||
236 | $criterionMock, |
||
237 | 3, |
||
238 | array( |
||
239 | array( |
||
240 | 'limitation' => null, |
||
241 | 'policies' => array($policy2), |
||
242 | ), |
||
243 | array( |
||
244 | 'limitation' => null, |
||
245 | 'policies' => array($policy1), |
||
246 | ), |
||
247 | ), |
||
248 | new Criterion\LogicalOr( |
||
249 | array( |
||
250 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
251 | $criterionMock, |
||
252 | ) |
||
253 | ), |
||
254 | ), |
||
255 | array( |
||
256 | $criterionMock, |
||
257 | 2, |
||
258 | array( |
||
259 | array( |
||
260 | 'limitation' => $limitationMock, |
||
261 | 'policies' => array($policy1), |
||
262 | ), |
||
263 | ), |
||
264 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
265 | ), |
||
266 | array( |
||
267 | $criterionMock, |
||
268 | 4, |
||
269 | array( |
||
270 | array( |
||
271 | 'limitation' => $limitationMock, |
||
272 | 'policies' => array($policy1), |
||
273 | ), |
||
274 | array( |
||
275 | 'limitation' => $limitationMock, |
||
276 | 'policies' => array($policy1), |
||
277 | ), |
||
278 | ), |
||
279 | new Criterion\LogicalOr( |
||
280 | array( |
||
281 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
282 | new Criterion\LogicalAnd(array($criterionMock, $criterionMock)), |
||
283 | ) |
||
284 | ), |
||
285 | ), |
||
286 | array( |
||
287 | $criterionMock, |
||
288 | 1, |
||
289 | array( |
||
290 | array( |
||
291 | 'limitation' => $limitationMock, |
||
292 | 'policies' => array(new Policy(array('limitations' => '*'))), |
||
293 | ), |
||
294 | ), |
||
295 | $criterionMock, |
||
296 | ), |
||
297 | array( |
||
298 | $criterionMock, |
||
299 | 2, |
||
300 | array( |
||
301 | array( |
||
302 | 'limitation' => $limitationMock, |
||
303 | 'policies' => array(new Policy(array('limitations' => '*'))), |
||
304 | ), |
||
305 | array( |
||
306 | 'limitation' => $limitationMock, |
||
307 | 'policies' => array(new Policy(array('limitations' => '*'))), |
||
308 | ), |
||
309 | ), |
||
310 | new Criterion\LogicalOr(array($criterionMock, $criterionMock)), |
||
311 | ), |
||
312 | ); |
||
313 | } |
||
314 | |||
452 |