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 |
||
10 | class Settlement extends Service implements SettlementInterface |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @var SoapClient|null |
||
15 | */ |
||
16 | private $_client; |
||
17 | |||
18 | /** |
||
19 | * City constructor |
||
20 | * @throws N11Exception|\SoapFault |
||
21 | */ |
||
22 | public function __construct() |
||
27 | |||
28 | /** |
||
29 | * @param string $startDate |
||
30 | * @param int $endDate |
||
31 | * @param int $currentPage |
||
32 | * @param int $pageSize |
||
33 | * @return object |
||
34 | * @description Seçilen tarih aralığına göre ödeme bilgilerini listeleyen servis. |
||
35 | */ |
||
36 | View Code Duplication | public function getSettlementList(string $startDate, int $endDate, int $currentPage = 1, int $pageSize = 100): object { |
|
45 | |||
46 | /** |
||
47 | * @param string $date |
||
48 | * @param int $currentPage |
||
49 | * @param int $pageSize |
||
50 | * @return object |
||
51 | * @description GetSettlementList metodu ile listelenen ödemelere ait ayrıntıları gösteren metod. Belirli bir gün seçilerek, o güne ait satış/uzlaşma detayları getirilir. |
||
52 | */ |
||
53 | View Code Duplication | public function getSettlementDetail(string $date, int $currentPage = 1, int $pageSize = 100): object { |
|
61 | |||
62 | } |
||
63 |
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.