| Conditions | 1 |
| Paths | 1 |
| Total Lines | 80 |
| Code Lines | 57 |
| 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 |
||
| 29 | public function __construct() |
||
| 30 | { |
||
| 31 | $this->database = [ |
||
| 32 | [ |
||
| 33 | 'title' => 'How to start a perfect day', |
||
| 34 | 'summary' => 'Good to know...', |
||
| 35 | 'category' => ['useful' => 'Useful infos'], |
||
| 36 | 'tags' => ['php' => 'PHP', 'coding' => 'Coding'], |
||
| 37 | 'illustration'=> '/data/upload/filesystem/images/Nature.jpg', |
||
| 38 | 'path' => 'posts/view/a_perfect_day.html', |
||
| 39 | 'publishedAt' => time(), |
||
| 40 | 'location' => 'München', |
||
| 41 | 'author' => [ |
||
| 42 | 'name' => 'Amadeus', |
||
| 43 | 'username'=> 'a.madeus', |
||
| 44 | 'avatar' => '/data/upload/avatars/a.madeus.png', |
||
| 45 | 'mood' => ['feels cozy', 'hugging'], |
||
| 46 | ], |
||
| 47 | 'contentLead' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod |
||
| 48 | tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At |
||
| 49 | vero eos et accusam et justo duo dolores et ea rebum.' |
||
| 50 | ], |
||
| 51 | [ |
||
| 52 | 'title' => 'Just an idea', |
||
| 53 | 'summary' => null, |
||
| 54 | 'category' => ['posts' => 'Posts'], |
||
| 55 | 'tags' => ['php' => 'PHP', 'coding' => 'Coding'], |
||
| 56 | 'illustration'=> null, |
||
| 57 | 'path' => 'notepad/just_an_idea.html', |
||
| 58 | 'publishedAt' => time(), |
||
| 59 | 'location' => null, |
||
| 60 | 'author' => [ |
||
| 61 | 'name' => 'Gabor', |
||
| 62 | 'username'=> 'gabor', |
||
| 63 | 'avatar' => '/data/upload/avatars/gabor.png', |
||
| 64 | 'mood' => null, |
||
| 65 | ], |
||
| 66 | 'contentLead' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod |
||
| 67 | tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At |
||
| 68 | vero eos et accusam et justo duo dolores et ea rebum.' |
||
| 69 | ], |
||
| 70 | [ |
||
| 71 | 'title' => 'An Owl', |
||
| 72 | 'category' => ['events' => 'Events'], |
||
| 73 | 'tags' => ['munich' => 'Munich'], |
||
| 74 | 'illustration'=> '/data/upload/filesystem/images/Owl.jpg', |
||
| 75 | 'path' => 'nature/birds/notes/an_owl.html', |
||
| 76 | 'publishedAt' => time(), |
||
| 77 | 'location' => 'München', |
||
| 78 | 'author' => [ |
||
| 79 | 'name' => 'Amadeus', |
||
| 80 | 'username'=> 'a.madeus', |
||
| 81 | 'avatar' => '/data/upload/avatars/a.madeus.png', |
||
| 82 | 'mood' => ['feels cozy', 'hugging'], |
||
| 83 | ], |
||
| 84 | 'contentLead' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod |
||
| 85 | tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At |
||
| 86 | vero eos et accusam et justo duo dolores et ea rebum.' |
||
| 87 | ], |
||
| 88 | [ |
||
| 89 | 'title' => 'The new Spiderman movie', |
||
| 90 | 'summary' => 'I didn\'t see it yet', |
||
| 91 | 'category' => ['something' => 'Something'], |
||
| 92 | 'tags' => ['munich' => 'Munich'], |
||
| 93 | 'illustration'=> '/data/upload/filesystem/images/Spider.jpg', |
||
| 94 | 'path' => 'nature/arthropods/spidey.html', |
||
| 95 | 'publishedAt' => time(), |
||
| 96 | 'location' => 'München', |
||
| 97 | 'author' => [ |
||
| 98 | 'name' => 'Amadeus', |
||
| 99 | 'username'=> 'a.madeus', |
||
| 100 | 'avatar' => '/data/upload/avatars/a.madeus.png', |
||
| 101 | 'mood' => ['feels cozy', 'hugging'], |
||
| 102 | ], |
||
| 103 | 'contentLead' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod |
||
| 104 | tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At |
||
| 105 | vero eos et accusam et justo duo dolores et ea rebum.' |
||
| 106 | ] |
||
| 107 | ]; |
||
| 108 | } |
||
| 109 | |||
| 163 |