| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 112 | public function provideCasesForTestChange(): iterable |
||
| 113 | { |
||
| 114 | yield 'Empty string' => [ |
||
| 115 | '', |
||
| 116 | new Indentation(4, Indentation::TYPE_SPACE), |
||
| 117 | '', |
||
| 118 | ]; |
||
| 119 | |||
| 120 | yield 'No indentation' => [ |
||
| 121 | '<ul></ul>', |
||
| 122 | new Indentation(4, Indentation::TYPE_SPACE), |
||
| 123 | '<ul></ul>', |
||
| 124 | ]; |
||
| 125 | |||
| 126 | yield 'Two spaces to four spaces' => [ |
||
| 127 | "<div>\n <ul>\n <li>yay</li>\n </ul>\n</div>", |
||
| 128 | new Indentation(4, Indentation::TYPE_SPACE), |
||
| 129 | "<div>\n <ul>\n <li>yay</li>\n </ul>\n</div>", |
||
| 130 | ]; |
||
| 131 | |||
| 132 | yield 'Four spaces to two spaces' => [ |
||
| 133 | "<div>\n <ul>\n <li>yay</li>\n </ul>\n</div>", |
||
| 134 | new Indentation(2, Indentation::TYPE_SPACE), |
||
| 135 | "<div>\n <ul>\n <li>yay</li>\n </ul>\n</div>", |
||
| 136 | ]; |
||
| 137 | |||
| 138 | yield 'Two spaces to tabs' => [ |
||
| 139 | "<div>\n <ul>\n <li>yay</li>\n </ul>\n</div>", |
||
| 140 | new Indentation(1, Indentation::TYPE_TAB), |
||
| 141 | "<div>\n\t<ul>\n\t\t<li>yay</li>\n\t</ul>\n</div>", |
||
| 142 | ]; |
||
| 143 | |||
| 144 | yield 'Four spaces to tabs' => [ |
||
| 145 | "<div>\n <ul>\n <li>yay</li>\n </ul>\n</div>", |
||
| 146 | new Indentation(1, Indentation::TYPE_TAB), |
||
| 147 | "<div>\n\t<ul>\n\t\t<li>yay</li>\n\t</ul>\n</div>", |
||
| 148 | ]; |
||
| 149 | |||
| 150 | yield 'Tabs to four spaces' => [ |
||
| 151 | "<div>\n\t<ul>\n\t\t<li>yay</li>\n\t</ul>\n</div>", |
||
| 152 | new Indentation(4, Indentation::TYPE_SPACE), |
||
| 153 | "<div>\n <ul>\n <li>yay</li>\n </ul>\n</div>", |
||
| 154 | ]; |
||
| 155 | |||
| 156 | yield 'Two tabs to two spaces' => [ |
||
| 157 | "<div>\n\t\t<ul>\n\t\t\t\t<li>yay</li>\n\t\t</ul>\n</div>", |
||
| 158 | new Indentation(2, Indentation::TYPE_SPACE), |
||
| 159 | "<div>\n <ul>\n <li>yay</li>\n </ul>\n</div>", |
||
| 160 | ]; |
||
| 161 | |||
| 162 | yield 'Newlines are preserved' => [ |
||
| 163 | "\n<div>\n <ul>\r\n <li>yay</li>\r </ul>\n</div>\n\n", |
||
| 164 | new Indentation(4, Indentation::TYPE_SPACE), |
||
| 165 | "\n<div>\n <ul>\r\n <li>yay</li>\r </ul>\n</div>\n\n", |
||
| 166 | ]; |
||
| 179 |