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 |
||
23 | View Code Duplication | class BeforeDenormalizationEvent extends Event |
|
24 | { |
||
25 | /** |
||
26 | * @var mixed |
||
27 | */ |
||
28 | private $data; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $type; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $format; |
||
39 | |||
40 | /** |
||
41 | * @var array |
||
42 | */ |
||
43 | private $context; |
||
44 | |||
45 | /** |
||
46 | * Constructor. |
||
47 | * |
||
48 | * @param mixed $data |
||
49 | * @param string $type |
||
50 | * @param string $format |
||
51 | * @param array $context |
||
52 | */ |
||
53 | 5 | public function __construct($data, string $type, string $format, array $context) |
|
60 | |||
61 | /** |
||
62 | * Get data |
||
63 | * |
||
64 | * @return mixed |
||
65 | */ |
||
66 | 1 | public function getData() |
|
70 | |||
71 | /** |
||
72 | * Get type |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | 1 | public function getType(): string |
|
80 | |||
81 | /** |
||
82 | * Get format |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 1 | public function getFormat(): string |
|
90 | |||
91 | /** |
||
92 | * Get context |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | 1 | public function getContext(): array |
|
100 | } |
||
101 |
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.