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 |
||
| 9 | class Availability extends Client implements AvailabilityInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Create availability |
||
| 13 | * |
||
| 14 | * @return \Rezdy\Interfaces\QueryInterface |
||
| 15 | */ |
||
| 16 | public function create(): QueryInterface |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Update availability |
||
| 27 | * |
||
| 28 | * @param string $sessionId |
||
| 29 | * |
||
| 30 | * @return \Rezdy\Interfaces\QueryInterface |
||
| 31 | */ |
||
| 32 | public function update(string $sessionId): QueryInterface |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Delete availability |
||
| 43 | * |
||
| 44 | * @param string $sessionId |
||
| 45 | * |
||
| 46 | * @return \Rezdy\Interfaces\QueryInterface |
||
| 47 | */ |
||
| 48 | public function delete(string $sessionId): QueryInterface |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Search availability |
||
| 59 | * |
||
| 60 | * @return \Rezdy\Interfaces\QueryInterface |
||
| 61 | */ |
||
| 62 | public function search(): QueryInterface |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Create availability batch |
||
| 73 | * |
||
| 74 | * @return \Rezdy\Interfaces\QueryInterface |
||
| 75 | */ |
||
| 76 | public function createBatch(): QueryInterface |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Update availability starting at |
||
| 87 | * |
||
| 88 | * @param string $productCode |
||
| 89 | * @param string $startTimeLocal |
||
| 90 | * |
||
| 91 | * @return \Rezdy\Interfaces\QueryInterface |
||
| 92 | */ |
||
| 93 | public function updateStartingAt(string $productCode, string $startTimeLocal): QueryInterface |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Delete availability starting at |
||
| 104 | * |
||
| 105 | * @param string $productCode |
||
| 106 | * @param string $startTimeLocal |
||
| 107 | * |
||
| 108 | * @return \Rezdy\Interfaces\QueryInterface |
||
| 109 | */ |
||
| 110 | public function deleteStartingAt(string $productCode, string $startTimeLocal): QueryInterface |
||
| 118 | |||
| 119 | } |
||
| 120 |