| Conditions | 1 |
| Paths | 1 |
| Total Lines | 74 |
| 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 |
||
| 17 | function let() |
||
| 18 | { |
||
| 19 | $translation = [ |
||
| 20 | 'locale' => 'en', |
||
| 21 | 'title' => 'English translation', |
||
| 22 | 'body' => 'Big text', |
||
| 23 | 'slug' => 'en-translation', |
||
| 24 | ]; |
||
| 25 | |||
| 26 | $categoryTranslation = [ |
||
| 27 | 'locale' => 'en', |
||
| 28 | 'title' => 'English category translation', |
||
| 29 | 'description' => 'Big category text', |
||
| 30 | ]; |
||
| 31 | |||
| 32 | $category = [ |
||
| 33 | 'id' => '3', |
||
| 34 | 'translations' => ['en' => $categoryTranslation], |
||
| 35 | 'enabled' => 1, |
||
| 36 | 'dataParent' => '11', |
||
| 37 | 'parentRootId' => '123', |
||
| 38 | 'createdAt' => ['date' => '2011-05-19 20:46:21.000000', 'timezone_type' => 3, 'timezone' => 'UTC'], |
||
| 39 | 'updatedAt' => ['date' => '2016-01-11 00:00:00.000000', 'timezone_type' => 3, 'timezone' => 'UTC'], |
||
| 40 | 'inheritance_status' => 'none', |
||
| 41 | ]; |
||
| 42 | |||
| 43 | $media = [ |
||
| 44 | 'id' => '5', |
||
| 45 | 'filename' => 'apple-box', |
||
| 46 | 'originalFilename' => 'Apple Box', |
||
| 47 | 'originalFilenameSlugged' => 'App..Box.jpeg', |
||
| 48 | 'description' => 'The biggest image', |
||
| 49 | 'title' => 'Apple Box Title', |
||
| 50 | 'visible' => 1, |
||
| 51 | 'created_at' => '2011-05-19 20:46:21.000000', |
||
| 52 | 'updated_at' => '2016-01-11 00:00:00.000000', |
||
| 53 | 'mime' => 'image/jpeg', |
||
| 54 | 'type' => 'image', |
||
| 55 | 'size' => 11345, |
||
| 56 | 'extension' => 'jpg', |
||
| 57 | 'category_ids' => [1, 2, 3], |
||
| 58 | 'link_url' => 'http://site.com/media/original/apple-box.jpg', |
||
| 59 | ]; |
||
| 60 | |||
| 61 | $articleMedia = [ |
||
| 62 | 'id' => '10', |
||
| 63 | 'display_order' => '5', |
||
| 64 | 'media' => $media, |
||
| 65 | ]; |
||
| 66 | |||
| 67 | $data = [ |
||
| 68 | 'id' => '7', |
||
| 69 | 'translations' => ['en' => $translation], |
||
| 70 | 'categories' => [$category], |
||
| 71 | 'medias' => [$articleMedia], |
||
| 72 | 'media_limit' => '9', |
||
| 73 | 'status' => 'published', |
||
| 74 | 'display_print_button' => 1, |
||
| 75 | 'display_print_address' => 0, |
||
| 76 | 'with_return_button' => 1, |
||
| 77 | 'show_creation_date' => 1, |
||
| 78 | 'show_image_caption' => 0, |
||
| 79 | 'auto_play_slider' => 1, |
||
| 80 | 'routes' => ['en' => 'simple-route-path'], |
||
| 81 | 'share_on_facebook' => 1, |
||
| 82 | 'display_order' => '5', |
||
| 83 | 'dataParent' => '89', |
||
| 84 | 'createdAt' => ['date' => '2011-05-19 20:46:21.000000', 'timezone_type' => 3, 'timezone' => 'UTC'], |
||
| 85 | 'updatedAt' => ['date' => '2016-01-11 00:00:00.000000', 'timezone_type' => 3, 'timezone' => 'UTC'], |
||
| 86 | 'inheritance_status' => 'inherited', |
||
| 87 | ]; |
||
| 88 | |||
| 89 | $this->beConstructedWith($data); |
||
| 90 | } |
||
| 91 | |||
| 115 |