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 | final class CoordinatesTest extends TestCase |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @test |
||
| 17 | * @dataProvider getCoordinates |
||
| 18 | */ |
||
| 19 | public function coordinate(float $latitude, float $longitude, float $accuracyMeters) |
||
| 27 | |||
| 28 | View Code Duplication | public function getCoordinates(): array |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @test |
||
| 39 | * @expectedException \LauLamanApps\IzettleApi\API\Purchase\Exceptions\InvalidLatitudeException |
||
| 40 | * @dataProvider getInvalidLatitude |
||
| 41 | */ |
||
| 42 | public function invalidLatitude(float $latitude) |
||
| 46 | |||
| 47 | public function getInvalidLatitude(): array |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @test |
||
| 57 | * @expectedException \LauLamanApps\IzettleApi\API\Purchase\Exceptions\InvalidLongitudeException |
||
| 58 | * @dataProvider getInvalidLongitude |
||
| 59 | */ |
||
| 60 | public function invalidLongitude(float $longitude) |
||
| 64 | |||
| 65 | public function getInvalidLongitude(): array |
||
| 72 | } |
||
| 73 |