Conditions | 10 |
Paths | 22 |
Total Lines | 25 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 10.2368 |
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 |
||
33 | * Requested profile pictures (in up to 4 sizes each) |
||
34 | * |
||
35 | * This method overrides the default getPhotos method and returns a nice array |
||
36 | * |
||
37 | * @return PhotoSize[] |
||
38 | */ |
||
39 | 1 | public function getPhotos() |
|
40 | { |
||
41 | 1 | $all_photos = []; |
|
42 | |||
43 | 1 | if ($these_photos = $this->getProperty('photos')) { |
|
44 | 1 | foreach ($these_photos as $photos) { |
|
45 | 1 | $new_photos = []; |
|
46 | 1 | foreach ($photos as $photo) { |
|
47 | 1 | $new_photos[] = new PhotoSize($photo); |
|
48 | } |
||
49 | 1 | $all_photos[] = $new_photos; |
|
50 | } |
||
51 | } |
||
52 | |||
53 | 1 | return $all_photos; |
|
54 | } |
||
55 | } |
||
56 |