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 |
||
24 | View Code Duplication | class AfterDenormalizationEvent extends Event |
|
25 | { |
||
26 | /** |
||
27 | * @var mixed |
||
28 | */ |
||
29 | private $data; |
||
30 | |||
31 | /** |
||
32 | * @var ResourceInterface |
||
33 | */ |
||
34 | private $resource; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $format; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | private $context; |
||
45 | |||
46 | /** |
||
47 | * Constructor. |
||
48 | * |
||
49 | * @param mixed $data |
||
50 | * @param ResourceInterface $resource |
||
51 | * @param string $format |
||
52 | * @param array $context |
||
53 | */ |
||
54 | 6 | public function __construct($data, ResourceInterface $resource, string $format, array $context) |
|
61 | |||
62 | /** |
||
63 | * Get data |
||
64 | * |
||
65 | * @return mixed |
||
66 | */ |
||
67 | 1 | public function getData() |
|
71 | |||
72 | /** |
||
73 | * Get denormalized resource |
||
74 | * |
||
75 | * @return ResourceInterface |
||
76 | */ |
||
77 | 3 | public function getResource(): ResourceInterface |
|
81 | |||
82 | /** |
||
83 | * Get format |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | 1 | public function getFormat(): string |
|
91 | |||
92 | /** |
||
93 | * Get context |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | 1 | public function getContext(): array |
|
101 | } |
||
102 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.