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 |
||
| 17 | final class FailedRDMAssertionException extends ErrorException implements FailedRDMAssertionExceptionInterface |
||
|
|
|||
| 18 | { |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | private $type; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var array<mixed> |
||
| 27 | */ |
||
| 28 | private $parameters; |
||
| 29 | |||
| 30 | 5 | public function __construct(string $message, string $type, array $parameters) |
|
| 37 | |||
| 38 | 1 | public function getType(): string |
|
| 39 | { |
||
| 40 | 1 | return $this->type; |
|
| 41 | } |
||
| 42 | |||
| 43 | 1 | public function getParameters(): array |
|
| 44 | { |
||
| 45 | 1 | return $this->parameters; |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param mixed $expectedService |
||
| 50 | * @param mixed $actualService |
||
| 51 | */ |
||
| 52 | 3 | public static function expectedDifferentService( |
|
| 90 | |||
| 91 | } |
||
| 92 |