| 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 |
||
| 71 | protected function getFeedItem() |
||
| 72 | { |
||
| 73 | $authorItem = new ApplicationItem( |
||
| 74 | Microformats::FORMAT, |
||
| 75 | (object)['profile' => MicroformatsFactory::MF2_PROFILE_URI, 'name' => 'h-card'], |
||
| 76 | [ |
||
| 77 | (object)[ |
||
| 78 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 79 | 'name' => 'p-name', |
||
| 80 | 'values' => [ |
||
| 81 | new StringValue('John Doe') |
||
| 82 | ] |
||
| 83 | ], |
||
| 84 | (object)[ |
||
| 85 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 86 | 'name' => 'u-email', |
||
| 87 | 'values' => [ |
||
| 88 | new StringValue('[email protected]') |
||
| 89 | ] |
||
| 90 | ] |
||
| 91 | ] |
||
| 92 | ); |
||
| 93 | |||
| 94 | |||
| 95 | $entryItem = new ApplicationItem( |
||
| 96 | Microformats::FORMAT, |
||
| 97 | (object)['profile' => MicroformatsFactory::MF2_PROFILE_URI, 'name' => 'h-entry'], |
||
| 98 | [ |
||
| 99 | (object)[ |
||
| 100 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 101 | 'name' => 'p-name', |
||
| 102 | 'values' => [ |
||
| 103 | new StringValue('Famous blog post') |
||
| 104 | ] |
||
| 105 | ], |
||
| 106 | (object)[ |
||
| 107 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 108 | 'name' => 'p-author', |
||
| 109 | 'values' => [ |
||
| 110 | $authorItem |
||
| 111 | ] |
||
| 112 | ] |
||
| 113 | ] |
||
| 114 | ); |
||
| 115 | |||
| 116 | |||
| 117 | $feedItem = new ApplicationItem( |
||
| 118 | Microformats::FORMAT, |
||
| 119 | (object)['profile' => MicroformatsFactory::MF2_PROFILE_URI, 'name' => 'h-feed'], |
||
| 120 | [ |
||
| 121 | (object)[ |
||
| 122 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 123 | 'name' => 'p-name', |
||
| 124 | 'values' => [ |
||
| 125 | new StringValue('John Doe\'s Blog') |
||
| 126 | ] |
||
| 127 | ], |
||
| 128 | (object)[ |
||
| 129 | 'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
||
| 130 | 'name' => 'p-author', |
||
| 131 | 'values' => [ |
||
| 132 | $authorItem |
||
| 133 | ] |
||
| 134 | ] |
||
| 135 | ], |
||
| 136 | [$entryItem, $entryItem] |
||
| 137 | ); |
||
| 138 | |||
| 139 | return new Item($feedItem); |
||
| 140 | } |
||
| 141 | } |
||
| 142 |