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 | View Code Duplication | class GetCodeBooksChanges extends iDokladAbstractFunction |
|
|
|||
14 | { |
||
15 | /** @var \DateTime $lastCheckedAt */ |
||
16 | protected $lastCheckedAt; |
||
17 | |||
18 | /** |
||
19 | * @param \DateTime $lastCheckedAt |
||
20 | */ |
||
21 | public function __construct(\DateTime $lastCheckedAt) |
||
25 | |||
26 | /** |
||
27 | * Get iDokladModelInterface class. |
||
28 | * |
||
29 | * @see iDokladModelInterface |
||
30 | * |
||
31 | * @return string |
||
32 | */ |
||
33 | public function getModelClass(): string |
||
37 | |||
38 | /** |
||
39 | * GET|POST|PUT|DELETE e.g. |
||
40 | * |
||
41 | * @see iDoklad::request() |
||
42 | * |
||
43 | * @return string |
||
44 | */ |
||
45 | public function getHttpMethod(): string |
||
49 | |||
50 | /** |
||
51 | * Return base URI, e.g. /invoices; /invoice/1/edit and so on. |
||
52 | * |
||
53 | * @see iDoklad::call() |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | public function getUri(): string |
||
64 | |||
65 | /** |
||
66 | * Vrátí seznam parametrů, které se předají GuzzleHttp\Client. |
||
67 | * |
||
68 | * @see \GuzzleHttp\Client::request() |
||
69 | * @see iDoklad::call() |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | public function getGuzzleOptions(): array |
||
77 | } |
||
78 |
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.