| Conditions | 1 |
| Paths | 1 |
| Total Lines | 123 |
| Code Lines | 104 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 173 | public function testGetJobs(): void |
||
| 174 | { |
||
| 175 | $jobs = $this->getJobs(); |
||
| 176 | $this->assertCount(17, $jobs); |
||
| 177 | |||
| 178 | $job = $jobs[0]; |
||
| 179 | $this->assertSame("TestCase::testState", $job->name); |
||
| 180 | $this->assertSame([$this, "testState", ], $job->callback); |
||
| 181 | $this->assertSame([], $job->params); |
||
| 182 | $this->assertFalse((bool) $job->skip); |
||
| 183 | $this->assertCount(1, $job->onAfterExecute); |
||
| 184 | |||
| 185 | $job = $jobs[1]; |
||
| 186 | $this->assertSame("TestCase::testParams", $job->name); |
||
| 187 | $this->assertSame([$this, "testParams", ], $job->callback); |
||
| 188 | $this->assertSame(["abc", ], $job->params); |
||
| 189 | $this->assertFalse((bool) $job->skip); |
||
| 190 | $this->assertCount(1, $job->onAfterExecute); |
||
| 191 | |||
| 192 | $job = $jobs[2]; |
||
| 193 | $this->assertSame("TestCase::testParams", $job->name); |
||
| 194 | $this->assertSame([$this, "testParams", ], $job->callback); |
||
| 195 | $this->assertSame(["adef", ], $job->params); |
||
| 196 | $this->assertFalse((bool) $job->skip); |
||
| 197 | $this->assertCount(1, $job->onAfterExecute); |
||
| 198 | |||
| 199 | $job = $jobs[3]; |
||
| 200 | $this->assertSame("TestCase::testParamsNoneProvided", $job->name); |
||
| 201 | $this->assertSame([$this, "testParamsNoneProvided", ], $job->callback); |
||
| 202 | $this->assertSame([], $job->params); |
||
| 203 | $this->assertSame("Method requires at least 1 parameter but data provider does not provide any.", $job->skip); |
||
| 204 | $this->assertCount(1, $job->onAfterExecute); |
||
| 205 | |||
| 206 | $job = $jobs[4]; |
||
| 207 | $this->assertSame("Custom name", $job->name); |
||
| 208 | $this->assertSame([$this, "testTestName", ], $job->callback); |
||
| 209 | $this->assertSame([], $job->params); |
||
| 210 | $this->assertFalse((bool) $job->skip); |
||
| 211 | $this->assertCount(1, $job->onAfterExecute); |
||
| 212 | |||
| 213 | $job = $jobs[5]; |
||
| 214 | $this->assertSame("Skip", $job->name); |
||
| 215 | $this->assertSame([$this, "testSkip", ], $job->callback); |
||
| 216 | $this->assertSame([], $job->params); |
||
| 217 | $this->assertTrue((bool) $job->skip); |
||
| 218 | $this->assertCount(1, $job->onAfterExecute); |
||
| 219 | |||
| 220 | $job = $jobs[6]; |
||
| 221 | $this->assertSame("Boolean", $job->name); |
||
| 222 | $this->assertSame([$this, "testSkipBoolean", ], $job->callback); |
||
| 223 | $this->assertSame([], $job->params); |
||
| 224 | $this->assertTrue((bool) $job->skip); |
||
| 225 | $this->assertCount(1, $job->onAfterExecute); |
||
| 226 | |||
| 227 | $job = $jobs[7]; |
||
| 228 | $this->assertSame("Integer", $job->name); |
||
| 229 | $this->assertSame([$this, "testSkipInteger", ], $job->callback); |
||
| 230 | $this->assertSame([], $job->params); |
||
| 231 | $this->assertTrue((bool) $job->skip); |
||
| 232 | $this->assertCount(1, $job->onAfterExecute); |
||
| 233 | |||
| 234 | $job = $jobs[8]; |
||
| 235 | $this->assertSame("Float", $job->name); |
||
| 236 | $this->assertSame([$this, "testSkipFloat", ], $job->callback); |
||
| 237 | $this->assertSame([], $job->params); |
||
| 238 | $this->assertTrue((bool) $job->skip); |
||
| 239 | $this->assertCount(1, $job->onAfterExecute); |
||
| 240 | |||
| 241 | $job = $jobs[9]; |
||
| 242 | $this->assertSame("String", $job->name); |
||
| 243 | $this->assertSame([$this, "testSkipString", ], $job->callback); |
||
| 244 | $this->assertSame([], $job->params); |
||
| 245 | $this->assertTrue((bool) $job->skip); |
||
| 246 | $this->assertCount(1, $job->onAfterExecute); |
||
| 247 | |||
| 248 | $job = $jobs[10]; |
||
| 249 | $this->assertSame("PHP version", $job->name); |
||
| 250 | $this->assertSame([$this, "testSkipPhpVersion", ], $job->callback); |
||
| 251 | $this->assertSame([], $job->params); |
||
| 252 | $this->assertTrue((bool) $job->skip); |
||
| 253 | $this->assertCount(1, $job->onAfterExecute); |
||
| 254 | |||
| 255 | $job = $jobs[11]; |
||
| 256 | $this->assertSame("CGI sapi", $job->name); |
||
| 257 | $this->assertSame([$this, "testCgiSapi", ], $job->callback); |
||
| 258 | $this->assertSame([], $job->params); |
||
| 259 | $this->assertTrue((bool) $job->skip); |
||
| 260 | $this->assertCount(1, $job->onAfterExecute); |
||
| 261 | |||
| 262 | $job = $jobs[12]; |
||
| 263 | $this->assertSame("Extension", $job->name); |
||
| 264 | $this->assertSame([$this, "testSkipExtension", ], $job->callback); |
||
| 265 | $this->assertSame([], $job->params); |
||
| 266 | $this->assertTrue((bool) $job->skip); |
||
| 267 | $this->assertCount(1, $job->onAfterExecute); |
||
| 268 | |||
| 269 | $job = $jobs[13]; |
||
| 270 | $this->assertSame("No assertions", $job->name); |
||
| 271 | $this->assertSame([$this, "testNoAssertions", ], $job->callback); |
||
| 272 | $this->assertSame([], $job->params); |
||
| 273 | $this->assertFalse((bool) $job->skip); |
||
| 274 | $this->assertCount(1, $job->onAfterExecute); |
||
| 275 | |||
| 276 | $job = $jobs[14]; |
||
| 277 | $this->assertSame("TestCase::testGetSuiteName", $job->name); |
||
| 278 | $this->assertSame([$this, "testGetSuiteName", ], $job->callback); |
||
| 279 | $this->assertSame([], $job->params); |
||
| 280 | $this->assertFalse((bool) $job->skip); |
||
| 281 | $this->assertCount(1, $job->onAfterExecute); |
||
| 282 | |||
| 283 | $job = $jobs[15]; |
||
| 284 | $this->assertSame("TestCase::testGetJobName", $job->name); |
||
| 285 | $this->assertSame([$this, "testGetJobName", ], $job->callback); |
||
| 286 | $this->assertSame([], $job->params); |
||
| 287 | $this->assertFalse((bool) $job->skip); |
||
| 288 | $this->assertCount(1, $job->onAfterExecute); |
||
| 289 | |||
| 290 | $job = $jobs[16]; |
||
| 291 | $this->assertSame("TestCase::testGetJobs", $job->name); |
||
| 292 | $this->assertSame([$this, "testGetJobs", ], $job->callback); |
||
| 293 | $this->assertSame([], $job->params); |
||
| 294 | $this->assertFalse((bool) $job->skip); |
||
| 295 | $this->assertCount(1, $job->onAfterExecute); |
||
| 296 | } |
||
| 298 |