| Conditions | 1 |
| Paths | 1 |
| Total Lines | 94 |
| Code Lines | 66 |
| 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 |
||
| 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 | |||
| 110 | /** |
||
| 111 | * Gets template map name or template file path. |
||
| 112 | * |
||
| 113 | * @return string |
||
| 114 | */ |
||
| 115 | public function getTemplateName() : string |
||
| 116 | { |
||
| 117 | return 'website-index'; |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Gets template data. |
||
| 122 | * |
||
| 123 | * @return array |
||
| 124 | */ |
||
| 125 | public function getTemplateData() : array |
||
| 126 | { |
||
| 127 | return [ |
||
| 128 | 'activeMenu' => '', |
||
| 129 | 'categories' => [ |
||
| 130 | ['url' => 'posts', 'title' => 'Posts', 'icon' => 'chrome_reader_mode', 'new' => 1], |
||
| 131 | ['url' => 'useful', 'title' => 'Useful infos', 'icon' => 'perm_device_information', 'new' => 0], |
||
| 132 | ['url' => 'events', 'title' => 'Events', 'icon' => 'event_note', 'new' => 0], |
||
| 133 | ['url' => 'something', 'title' => 'Something', 'icon' => null, 'new' => 8], |
||
| 134 | ], |
||
| 135 | 'tags' => [ |
||
| 136 | ['url' => 'php', 'title' => 'PHP', 'total' => 132, 'new' => 1], |
||
| 137 | ['url' => 'coding', 'title' => 'Coding', 'total' => 132, 'new' => 0], |
||
| 138 | ['url' => 'munich', 'title' => 'Munich', 'total' => 132, 'new' => 85] |
||
| 139 | ], |
||
| 140 | 'blogPosts' => $this->database, |
||
| 141 | 'fixPost' => [ |
||
| 142 | 'title' => 'Welcome to my blog!', |
||
| 143 | 'summary' => null, |
||
| 144 | 'category' => null, |
||
| 145 | 'tags' => null, |
||
| 146 | 'illustration'=> null, |
||
| 147 | 'path' => 'welcome.html', |
||
| 148 | 'publishedAt' => time(), |
||
| 149 | 'location' => null, |
||
| 150 | 'author' => [ |
||
| 151 | 'name' => 'Gabor', |
||
| 152 | 'username'=> 'gabor', |
||
| 153 | 'avatar' => '/data/upload/avatars/gabor.png', |
||
| 154 | 'mood' => null, |
||
| 155 | ], |
||
| 156 | 'contentLead' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod |
||
| 163 |