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 |
||
| 7 | class MoneyTest extends \PHPUnit\Framework\TestCase |
||
| 8 | { |
||
| 9 | public function testCreate() |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @dataProvider provideCompare |
||
| 18 | * |
||
| 19 | * @param Money $a |
||
| 20 | * @param Money $b |
||
| 21 | * @param int $expected |
||
| 22 | */ |
||
| 23 | public function testCompare(Money $a, Money $b, $expected) |
||
| 28 | |||
| 29 | public function provideCompare() |
||
| 42 | |||
| 43 | public function testExceptionWithDifferentCurrencies() |
||
| 52 | |||
| 53 | View Code Duplication | public function testEquals() |
|
| 62 | |||
| 63 | View Code Duplication | public function testLessThan() |
|
| 72 | |||
| 73 | View Code Duplication | public function testGreaterThan() |
|
| 82 | } |
||
| 83 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.