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 SubscriptionPeriodTest extends \PHPUnit_Framework_TestCase |
||
| 8 | { |
||
| 9 | |||
| 10 | /** @test */ |
||
| 11 | public function UnitMustBeValid() |
||
| 16 | |||
| 17 | /** @test */ |
||
| 18 | public function SettingUnitToWeeklyChecksMoment() |
||
| 24 | |||
| 25 | /** @test */ |
||
| 26 | public function SettingUnitToMonthlyChecksMoment() |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @test |
||
| 35 | * @dataProvider unitProvider |
||
| 36 | */ |
||
| 37 | public function UnitCanBeSetRight($unit) |
||
| 42 | |||
| 43 | /** @test */ |
||
| 44 | public function IntervalMustBeInteger() |
||
| 49 | |||
| 50 | /** @test */ |
||
| 51 | public function IntervalMustBePositive() |
||
| 56 | |||
| 57 | /** @test */ |
||
| 58 | public function IntervalMustNotBeTooBig() |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @test |
||
| 66 | * @dataProvider intProvider |
||
| 67 | */ |
||
| 68 | public function IntervalCanBeSetRight($interval) |
||
| 73 | |||
| 74 | /** @test */ |
||
| 75 | public function MomentMustBeInt() |
||
| 80 | |||
| 81 | /** @test */ |
||
| 82 | public function MomentMustBePositive() |
||
| 87 | |||
| 88 | /** @test */ |
||
| 89 | public function MomentMustNotBeTooBig() |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @test |
||
| 97 | * @dataProvider badUnitMomentComboProvider |
||
| 98 | */ |
||
| 99 | public function MomentChecksUnit($unit, $interval) |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @test |
||
| 107 | * @dataProvider intProvider |
||
| 108 | */ |
||
| 109 | public function MomentCanBeSetRight($moment) |
||
| 114 | |||
| 115 | View Code Duplication | public function unitProvider() |
|
| 123 | |||
| 124 | public function intProvider() |
||
| 133 | |||
| 134 | View Code Duplication | public function badUnitMomentComboProvider() |
|
| 141 | |||
| 142 | protected function createPeriod($unit = SubscriptionPeriod::UNIT_DAILY, $interval = 12, $moment = 6) |
||
| 146 | } |
||
| 147 |
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.