Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 8 | class NoopMiddlewareTest extends NimoTestCase |
||
| 9 | { |
||
| 10 | |||
| 11 | public function testNoopMiddleware() |
||
| 12 | { |
||
| 13 | $requst = $this->getRequestMock(); |
||
| 14 | $response = $this->getResponseMock(); |
||
| 15 | $handler = $this->assertedHandler($requst, $response); |
||
| 16 | $middleware = new NoopMiddleware(); |
||
| 17 | |||
| 18 | $actualResponse = $middleware->process($requst, $handler); |
||
| 19 | Assert::assertSame($response, $actualResponse); |
||
| 20 | } |
||
| 21 | } |
||
| 22 |