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 |
||
| 13 | class LuaInputStreamTest extends \PHPUnit_Framework_TestCase { |
||
| 14 | public function testSimpleNext() { |
||
| 18 | |||
| 19 | View Code Duplication | public function testMultipleLines() { |
|
| 28 | |||
| 29 | /** |
||
| 30 | * @expectedException \Vlaswinkel\Lua\ParseException |
||
| 31 | * @expectedExceptionMessage Simple error (1:1) |
||
| 32 | */ |
||
| 33 | public function testSimpleError() { |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @expectedException \Vlaswinkel\Lua\ParseException |
||
| 42 | * @expectedExceptionMessage Other error (2:1) |
||
| 43 | */ |
||
| 44 | View Code Duplication | public function testMultipleLineError() { |
|
| 52 | |||
| 53 | /** |
||
| 54 | * @expectedException \Vlaswinkel\Lua\ParseException |
||
| 55 | * @expectedExceptionMessage This error (1:2) |
||
| 56 | */ |
||
| 57 | View Code Duplication | public function testMultipleColumnError() { |
|
| 64 | |||
| 65 | /** |
||
| 66 | * @expectedException \Vlaswinkel\Lua\ParseException |
||
| 67 | * @expectedExceptionMessage Complex error (2:2) |
||
| 68 | */ |
||
| 69 | View Code Duplication | public function testMultipleLineAndColumnError() { |
|
| 80 | } |