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 | class PortDefinition implements \JsonSerializable |
||
14 | { |
||
15 | const DIC = self::class; |
||
16 | public $port = 0; |
||
17 | |||
18 | public $protocol = 'tcp'; |
||
19 | |||
20 | public $name = null; |
||
21 | |||
22 | public $labels = null; |
||
23 | |||
24 | 5 | public function __construct($data = []) |
|
33 | |||
34 | /** |
||
35 | * @inheritdoc |
||
36 | */ |
||
37 | View Code Duplication | public function jsonSerialize() |
|
45 | } |
||
46 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.