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 |
||
| 7 | class Content extends Entity |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @param array $array |
||
| 11 | */ |
||
| 12 | 57 | public function __construct(array $array = []) |
|
| 18 | |||
| 19 | /** |
||
| 20 | * @param string $id |
||
| 21 | * |
||
| 22 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 23 | * |
||
| 24 | * @return \Acquia\LiftClient\Entity\Content |
||
| 25 | */ |
||
| 26 | 36 | public function setId($id) |
|
| 35 | |||
| 36 | /** |
||
| 37 | * Gets the 'id' parameter. |
||
| 38 | * |
||
| 39 | * @return string |
||
| 40 | */ |
||
| 41 | 15 | public function getId() |
|
| 45 | |||
| 46 | /** |
||
| 47 | * @param string $contentConnectorId |
||
| 48 | * |
||
| 49 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 50 | * |
||
| 51 | * @return \Acquia\LiftClient\Entity\Content |
||
| 52 | */ |
||
| 53 | 33 | View Code Duplication | public function setContentConnectorId($contentConnectorId = 'content_hub') |
| 62 | |||
| 63 | /** |
||
| 64 | * Gets the 'content_connector_id' parameter. |
||
| 65 | * |
||
| 66 | * @return string |
||
| 67 | */ |
||
| 68 | 18 | public function getContentConnectorId() |
|
| 72 | |||
| 73 | /** |
||
| 74 | * @param string $baseUrl |
||
| 75 | * |
||
| 76 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 77 | * |
||
| 78 | * @return \Acquia\LiftClient\Entity\Content |
||
| 79 | */ |
||
| 80 | 33 | public function setBaseUrl($baseUrl) |
|
| 89 | |||
| 90 | /** |
||
| 91 | * Gets the 'base_url' parameter. |
||
| 92 | * |
||
| 93 | * @return string |
||
| 94 | */ |
||
| 95 | 12 | public function getBaseUrl() |
|
| 99 | |||
| 100 | /** |
||
| 101 | * @param ViewMode $viewMode |
||
| 102 | * |
||
| 103 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
| 104 | * |
||
| 105 | * @return \Acquia\LiftClient\Entity\Content |
||
| 106 | */ |
||
| 107 | 33 | public function setViewMode(ViewMode $viewMode) |
|
| 113 | |||
| 114 | /** |
||
| 115 | * Gets the 'id' parameter. |
||
| 116 | * |
||
| 117 | * @return viewMode |
||
| 118 | */ |
||
| 119 | 15 | public function getViewMode() |
|
| 125 | |||
| 126 | /** |
||
| 127 | * Gets the 'errors' parameter. |
||
| 128 | * |
||
| 129 | * @return Error|null The errors, if there were any |
||
| 130 | */ |
||
| 131 | 3 | public function getError() |
|
| 140 | } |
||
| 141 |