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 Goal extends Entity |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @param array $array |
||
| 12 | */ |
||
| 13 | 63 | public function __construct(array $array = []) |
|
| 17 | |||
| 18 | /** |
||
| 19 | * Sets the 'id' parameter. |
||
| 20 | * |
||
| 21 | * @param string $id |
||
| 22 | * |
||
| 23 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 24 | * |
||
| 25 | * @return \Acquia\LiftClient\Entity\Goal |
||
| 26 | */ |
||
| 27 | 15 | public function setId($id) |
|
| 36 | |||
| 37 | /** |
||
| 38 | * Gets the 'id' parameter. |
||
| 39 | * |
||
| 40 | * @return string The Identifier of the Goal |
||
| 41 | */ |
||
| 42 | 9 | public function getId() |
|
| 46 | |||
| 47 | /** |
||
| 48 | * Sets the 'name' parameter. |
||
| 49 | * |
||
| 50 | * @param string $name |
||
| 51 | * |
||
| 52 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 53 | * |
||
| 54 | * @return \Acquia\LiftClient\Entity\Goal |
||
| 55 | */ |
||
| 56 | 15 | public function setName($name) |
|
| 65 | |||
| 66 | /** |
||
| 67 | * Gets the 'name' parameter. |
||
| 68 | * |
||
| 69 | * @return string The Name of the Goal |
||
| 70 | */ |
||
| 71 | 9 | public function getName() |
|
| 75 | |||
| 76 | /** |
||
| 77 | * Sets the 'description' parameter. |
||
| 78 | * |
||
| 79 | * @param string $description |
||
| 80 | * |
||
| 81 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 82 | * |
||
| 83 | * @return \Acquia\LiftClient\Entity\Goal |
||
| 84 | */ |
||
| 85 | 15 | public function setDescription($description) |
|
| 94 | |||
| 95 | /** |
||
| 96 | * Gets the 'description' parameter. |
||
| 97 | * |
||
| 98 | * @return string The Description of the Goal |
||
| 99 | */ |
||
| 100 | 9 | public function getDescription() |
|
| 104 | |||
| 105 | /** |
||
| 106 | * Sets the 'rule_ids' parameter. |
||
| 107 | * |
||
| 108 | * @param array $ruleIds |
||
| 109 | * |
||
| 110 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 111 | * |
||
| 112 | * @return \Acquia\LiftClient\Entity\Goal |
||
| 113 | */ |
||
| 114 | 15 | View Code Duplication | public function setRuleIds(array $ruleIds) |
| 125 | |||
| 126 | /** |
||
| 127 | * Gets the 'rule_ids' parameter. |
||
| 128 | * |
||
| 129 | * @return array The Rule Identifiers |
||
| 130 | */ |
||
| 131 | 9 | public function getRuleIds() |
|
| 135 | |||
| 136 | /** |
||
| 137 | * Sets the 'site_ids' parameter. |
||
| 138 | * |
||
| 139 | * @param array $siteIds |
||
| 140 | * |
||
| 141 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 142 | * |
||
| 143 | * @return \Acquia\LiftClient\Entity\Goal |
||
| 144 | */ |
||
| 145 | 15 | View Code Duplication | public function setSiteIds(array $siteIds) |
| 156 | |||
| 157 | /** |
||
| 158 | * Gets the 'site_ids' parameter. |
||
| 159 | * |
||
| 160 | * @return array The Site Identifiers |
||
| 161 | */ |
||
| 162 | 9 | public function getSiteIds() |
|
| 166 | |||
| 167 | /** |
||
| 168 | * Sets the 'event_names' parameter. |
||
| 169 | * |
||
| 170 | * @param array $eventNames |
||
| 171 | * |
||
| 172 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 173 | * |
||
| 174 | * @return \Acquia\LiftClient\Entity\Goal |
||
| 175 | */ |
||
| 176 | 15 | View Code Duplication | public function setEventNames(array $eventNames) |
| 187 | |||
| 188 | /** |
||
| 189 | * Gets the 'rule_ids' parameter. |
||
| 190 | * |
||
| 191 | * @return array The Rule Identifiers |
||
| 192 | */ |
||
| 193 | 9 | public function getEventNames() |
|
| 197 | |||
| 198 | /** |
||
| 199 | * Sets the 'global' parameter. |
||
| 200 | * |
||
| 201 | * @param bool $global |
||
| 202 | * |
||
| 203 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 204 | * |
||
| 205 | * @return \Acquia\LiftClient\Entity\Goal |
||
| 206 | */ |
||
| 207 | 6 | public function setGlobal($global) |
|
| 216 | |||
| 217 | /** |
||
| 218 | * Gets the 'global' parameter. |
||
| 219 | * |
||
| 220 | * @return bool |
||
| 221 | */ |
||
| 222 | 9 | public function getGlobal() |
|
| 226 | |||
| 227 | /** |
||
| 228 | * Sets the 'value' parameter. |
||
| 229 | * |
||
| 230 | * @param float|int $value |
||
| 231 | * |
||
| 232 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 233 | * |
||
| 234 | * @return \Acquia\LiftClient\Entity\Goal |
||
| 235 | */ |
||
| 236 | 6 | public function setValue($value) |
|
| 245 | |||
| 246 | /** |
||
| 247 | * Gets the 'value' parameter. |
||
| 248 | * |
||
| 249 | * @return float |
||
| 250 | */ |
||
| 251 | 9 | public function getValue() |
|
| 255 | } |
||
| 256 |