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 |
||
| 20 | class PluginApiService |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Url for Api |
||
| 24 | * |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | private $apiUrl; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var EccubeConfig |
||
| 31 | */ |
||
| 32 | private $eccubeConfig; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var RequestStack |
||
| 36 | */ |
||
| 37 | private $requestStack; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * PluginApiService constructor. |
||
| 41 | * |
||
| 42 | * @param EccubeConfig $eccubeConfig |
||
| 43 | * @param RequestStack $requestStack |
||
| 44 | */ |
||
| 45 | public function __construct(EccubeConfig $eccubeConfig, RequestStack $requestStack) |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @return mixed |
||
| 53 | */ |
||
| 54 | public function getApiUrl() |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @param mixed $apiUrl |
||
| 65 | */ |
||
| 66 | public function setApiUrl($apiUrl) |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Get master data: category |
||
| 73 | * |
||
| 74 | * @return array($result, $info) |
||
|
|
|||
| 75 | */ |
||
| 76 | public function getCategory() |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Get plugins list |
||
| 85 | * |
||
| 86 | * @param array $data |
||
| 87 | * |
||
| 88 | * @return array($result, $info) |
||
| 89 | */ |
||
| 90 | public function getPlugins($data) |
||
| 102 | |||
| 103 | /** |
||
| 104 | * Get a plugin |
||
| 105 | * |
||
| 106 | * @param int|string $id Id or plugin code |
||
| 107 | * @return array [$result, $info] |
||
| 108 | */ |
||
| 109 | public function getPlugin($id) |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Get captcha image |
||
| 118 | * |
||
| 119 | * @return array($result, $info) |
||
| 120 | */ |
||
| 121 | public function getCaptcha() |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Get api key from captcha image |
||
| 132 | * |
||
| 133 | * @param array $data |
||
| 134 | * |
||
| 135 | * @return array($result, $info) |
||
| 136 | */ |
||
| 137 | public function postApiKey($data) |
||
| 149 | |||
| 150 | /** |
||
| 151 | * API post |
||
| 152 | * |
||
| 153 | * @param string $url |
||
| 154 | * @param array $data |
||
| 155 | * |
||
| 156 | * @return array($result, $info) |
||
| 157 | */ |
||
| 158 | public function postRequestApi($url, $data = []) |
||
| 197 | |||
| 198 | /** |
||
| 199 | * API request processing |
||
| 200 | * |
||
| 201 | * @param string $url |
||
| 202 | * @param array $data |
||
| 203 | * |
||
| 204 | * @return array($result, $info) |
||
| 205 | */ |
||
| 206 | public function getRequestApi($url, $data = []) |
||
| 236 | |||
| 237 | /** |
||
| 238 | * Get message |
||
| 239 | * |
||
| 240 | * @param $info |
||
| 241 | * |
||
| 242 | * @return string |
||
| 243 | */ |
||
| 244 | View Code Duplication | public function getResponseErrorMessage($info) |
|
| 256 | } |
||
| 257 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.