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 Slot extends \ArrayObject |
||
| 11 | { |
||
| 12 | use EntityValueTrait; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @param array $array |
||
| 16 | */ |
||
| 17 | public function __construct(array $array = []) |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Sets the 'id' parameter. |
||
| 24 | * |
||
| 25 | * @param string $id |
||
| 26 | * |
||
| 27 | * @return \Acquia\LiftClient\Entity\Slot |
||
| 28 | */ |
||
| 29 | public function setId($id) |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Gets the 'id' parameter. |
||
| 38 | * |
||
| 39 | * @return string |
||
| 40 | */ |
||
| 41 | public function getId() |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Sets the 'label' parameter. |
||
| 48 | * |
||
| 49 | * @param string $label |
||
| 50 | * |
||
| 51 | * @return \Acquia\LiftClient\Entity\Slot |
||
| 52 | */ |
||
| 53 | public function setLabel($label) |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Gets the 'id' parameter. |
||
| 62 | * |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | public function getLabel() |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Sets the 'description' parameter. |
||
| 72 | * |
||
| 73 | * @param string $description |
||
| 74 | * |
||
| 75 | * @return \Acquia\LiftClient\Entity\Slot |
||
| 76 | */ |
||
| 77 | public function setDescription($description) |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Gets the 'description' parameter. |
||
| 86 | * |
||
| 87 | * @return string |
||
| 88 | */ |
||
| 89 | public function getDescription() |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Sets the 'html' parameter. |
||
| 96 | * |
||
| 97 | * @param string $html |
||
| 98 | * |
||
| 99 | * @return \Acquia\LiftClient\Entity\Slot |
||
| 100 | */ |
||
| 101 | public function setHtml($html) |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Gets the 'html' parameter. |
||
| 110 | * |
||
| 111 | * @return string |
||
| 112 | */ |
||
| 113 | public function getHtml() |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Sets the 'status' parameter. |
||
| 120 | * |
||
| 121 | * @param bool $status |
||
| 122 | * |
||
| 123 | * @return \Acquia\LiftClient\Entity\Slot |
||
| 124 | */ |
||
| 125 | public function setStatus($status) |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Gets the 'status' parameter. |
||
| 138 | * |
||
| 139 | * @return bool |
||
| 140 | */ |
||
| 141 | public function getStatus() |
||
| 150 | |||
| 151 | /** |
||
| 152 | * Sets the 'visibility' parameter. |
||
| 153 | * |
||
| 154 | * @param \Acquia\LiftClient\Entity\Visibility $visibility |
||
| 155 | * |
||
| 156 | * @return \Acquia\LiftClient\Entity\Slot |
||
| 157 | */ |
||
| 158 | public function setVisibility(Visibility $visibility) |
||
| 165 | |||
| 166 | /** |
||
| 167 | * Gets the 'visibility' parameter. |
||
| 168 | * |
||
| 169 | * @return string |
||
| 170 | */ |
||
| 171 | public function getVisibility() |
||
| 177 | |||
| 178 | /** |
||
| 179 | * Gets the 'created' parameter. |
||
| 180 | * |
||
| 181 | * @return DateTime |
||
| 182 | */ |
||
| 183 | public function getCreated() |
||
| 190 | |||
| 191 | /** |
||
| 192 | * Gets the 'updated' parameter. |
||
| 193 | * |
||
| 194 | * @return DateTime |
||
| 195 | */ |
||
| 196 | public function getUpdated() |
||
| 203 | |||
| 204 | /** |
||
| 205 | * Returns the json representation of the current object. |
||
| 206 | * |
||
| 207 | * @return string |
||
| 208 | */ |
||
| 209 | View Code Duplication | public function json() |
|
| 217 | |||
| 218 | /** |
||
| 219 | * @param string $key |
||
| 220 | * @param string $default |
||
| 221 | * |
||
| 222 | * @return mixed |
||
| 223 | */ |
||
| 224 | protected function getEntityValue($key, $default) |
||
| 228 | } |
||
| 229 |