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 | ||
| 8 | class SlotManager extends ManagerBase | ||
| 9 | { | ||
| 10 | /** | ||
| 11 |      * {@inheritdoc} | ||
| 12 | */ | ||
| 13 | protected $queryParameters = [ | ||
| 14 | 'visible_on_page' => null, | ||
| 15 | 'status' => null, | ||
| 16 | ]; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * Get a list of slots. | ||
| 20 | * | ||
| 21 | * Example of how to structure the $options parameter: | ||
| 22 | * <code> | ||
| 23 | * $options = [ | ||
| 24 | * 'visible_on_page' => 'http://localhost/blog/*', | ||
| 25 | * 'status' => 'enabled', | ||
| 26 | * ]; | ||
| 27 | * </code> | ||
| 28 | * | ||
| 29 | 6 | * @see http://docs.decision-api.acquia.com/#slots_get | |
| 30 | * | ||
| 31 | * @param array $options | ||
| 32 | 6 | * | |
| 33 | 4 | * @throws \GuzzleHttp\Exception\RequestException | |
| 34 | 4 | * | |
| 35 | * @return \Acquia\LiftClient\Entity\Slot[] | ||
| 36 | 6 | */ | |
| 37 | 6 | View Code Duplication | public function query($options = []) | 
| 54 | |||
| 55 | /** | ||
| 56 | * Get a specific slot. | ||
| 57 | * | ||
| 58 | * Example of how to structure the $options parameter: | ||
| 59 | * | ||
| 60 | * @see http://docs.decision-api.acquia.com/#slots__slotId__get | ||
| 61 | * | ||
| 62 | * @param array $id | ||
| 63 | * | ||
| 64 | * @throws \GuzzleHttp\Exception\RequestException | ||
| 65 | * | ||
| 66 | 6 | * @return \Acquia\LiftClient\Entity\Slot | |
| 67 | */ | ||
| 68 | 6 | View Code Duplication | public function get($id) | 
| 78 | |||
| 79 | /** | ||
| 80 | * Add a slot. | ||
| 81 | * | ||
| 82 | * @param \Acquia\LiftClient\Entity\Slot $slot | ||
| 83 | * | ||
| 84 | * @throws \GuzzleHttp\Exception\RequestException | ||
| 85 | * | ||
| 86 | 6 | * @return \Acquia\LiftClient\Entity\Slot | |
| 87 | */ | ||
| 88 | 6 | View Code Duplication | public function add(Slot $slot) | 
| 97 | |||
| 98 | /** | ||
| 99 | * Deletes a slot by ID. | ||
| 100 | * | ||
| 101 | * @param string $id | ||
| 102 | * | ||
| 103 | * @throws \GuzzleHttp\Exception\RequestException | ||
| 104 | * | ||
| 105 | 6 | * @return bool | |
| 106 | */ | ||
| 107 | 6 | public function delete($id) | |
| 114 | } | ||
| 115 |