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 |
||
| 18 | class InvalidItemException extends \Exception |
||
|
|
|||
| 19 | { |
||
| 20 | private $messageArgs = []; |
||
| 21 | |||
| 22 | private $warning; |
||
| 23 | |||
| 24 | 72 | public function __construct($message = null, $messageArgs = [], $warning = false) |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @return array |
||
| 33 | */ |
||
| 34 | public function getMessageArgs() |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @return bool |
||
| 41 | */ |
||
| 42 | 14 | public function isWarning() |
|
| 46 | |||
| 47 | /** |
||
| 48 | * @return InvalidItemException |
||
| 49 | */ |
||
| 50 | View Code Duplication | public static function fromProductClass($errorMessage, ProductClass $ProductClass) |
|
| 62 | } |
||
| 63 |