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 |
||
7 | View Code Duplication | final class CreateOrderForEmissionICRequestShoes extends CreateOrderForEmissionICRequest |
|
|
|||
8 | { |
||
9 | /** |
||
10 | * @var string Контактное лицо |
||
11 | */ |
||
12 | private $contactPerson; |
||
13 | /** |
||
14 | * @var string Способ выпуска товаров в оборот |
||
15 | */ |
||
16 | private $releaseMethodType; |
||
17 | /** |
||
18 | * @var string Способ изготовления СИ |
||
19 | */ |
||
20 | private $createMethodType; |
||
21 | /** |
||
22 | * @var string Идентификатор производственного заказа |
||
23 | */ |
||
24 | private $productionOrderId; |
||
25 | |||
26 | /** |
||
27 | * @param string $contactPerson |
||
28 | * @param string $releaseMethodType |
||
29 | * @param string $createMethodType |
||
30 | * @param string $productionOrderId |
||
31 | * @param OrderProductShoes[] $products |
||
32 | */ |
||
33 | public function __construct( |
||
47 | |||
48 | public function getContactPerson(): string |
||
52 | |||
53 | public function getReleaseMethodType(): string |
||
57 | |||
58 | public function getCreateMethodType(): string |
||
62 | |||
63 | public function getProductionOrderId(): string |
||
67 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.