| Conditions | 1 |
| Paths | 1 |
| Total Lines | 70 |
| Code Lines | 42 |
| 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 |
||
| 125 | protected function getFeedItem() |
||
| 126 | { |
||
| 127 | $authorItem = new ApplicationItem( |
||
| 128 | Microformats::FORMAT, |
||
| 129 | (object)['profile' => MicroformatsFactory::MF2_PROFILE_URI, 'name' => 'h-card'], |
||
| 130 | [ |
||
| 131 | (object)[ |
||
| 132 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 133 | 'name' => 'name', |
||
| 134 | 'values' => [ |
||
| 135 | new StringValue('John Doe') |
||
| 136 | ] |
||
| 137 | ], |
||
| 138 | (object)[ |
||
| 139 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 140 | 'name' => 'email', |
||
| 141 | 'values' => [ |
||
| 142 | new StringValue('[email protected]') |
||
| 143 | ] |
||
| 144 | ] |
||
| 145 | ] |
||
| 146 | ); |
||
| 147 | |||
| 148 | |||
| 149 | $entryItem = new ApplicationItem( |
||
| 150 | Microformats::FORMAT, |
||
| 151 | (object)['profile' => MicroformatsFactory::MF2_PROFILE_URI, 'name' => 'h-entry'], |
||
| 152 | [ |
||
| 153 | (object)[ |
||
| 154 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 155 | 'name' => 'name', |
||
| 156 | 'values' => [ |
||
| 157 | new StringValue('Famous blog post') |
||
| 158 | ] |
||
| 159 | ], |
||
| 160 | (object)[ |
||
| 161 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 162 | 'name' => 'author', |
||
| 163 | 'values' => [ |
||
| 164 | $authorItem |
||
| 165 | ] |
||
| 166 | ] |
||
| 167 | ] |
||
| 168 | ); |
||
| 169 | |||
| 170 | |||
| 171 | $feedItem = new ApplicationItem( |
||
| 172 | Microformats::FORMAT, |
||
| 173 | (object)['profile' => MicroformatsFactory::MF2_PROFILE_URI, 'name' => 'h-feed'], |
||
| 174 | [ |
||
| 175 | (object)[ |
||
| 176 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 177 | 'name' => 'name', |
||
| 178 | 'values' => [ |
||
| 179 | new StringValue('John Doe\'s Blog') |
||
| 180 | ] |
||
| 181 | ], |
||
| 182 | (object)[ |
||
| 183 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 184 | 'name' => 'author', |
||
| 185 | 'values' => [ |
||
| 186 | $authorItem |
||
| 187 | ] |
||
| 188 | ] |
||
| 189 | ], |
||
| 190 | [$entryItem, $entryItem] |
||
| 191 | ); |
||
| 192 | |||
| 193 | return new Item($feedItem); |
||
| 194 | } |
||
| 195 | } |
||
| 196 |