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 |
||
| 19 | class PluginApiService |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * Url for Api |
||
| 23 | * |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | private $apiUrl; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var EccubeConfig |
||
| 30 | */ |
||
| 31 | private $eccubeConfig; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var RequestStack |
||
| 35 | */ |
||
| 36 | private $requestStack; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * PluginApiService constructor. |
||
| 40 | * @param EccubeConfig $eccubeConfig |
||
| 41 | * @param RequestStack $requestStack |
||
| 42 | */ |
||
| 43 | public function __construct(EccubeConfig $eccubeConfig, RequestStack $requestStack) |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @return mixed |
||
| 51 | */ |
||
| 52 | public function getApiUrl() |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @param mixed $apiUrl |
||
| 63 | */ |
||
| 64 | public function setApiUrl($apiUrl) |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Get master data: category |
||
| 71 | * |
||
| 72 | * @return array($result, $info) |
||
|
|
|||
| 73 | */ |
||
| 74 | public function getCategory() |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Get plugins list |
||
| 83 | * |
||
| 84 | * @param array $data |
||
| 85 | * @return array($result, $info) |
||
| 86 | */ |
||
| 87 | public function getPlugins($data) |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Get captcha image |
||
| 102 | * |
||
| 103 | * @return array($result, $info) |
||
| 104 | */ |
||
| 105 | public function getCaptcha() |
||
| 113 | |||
| 114 | /** |
||
| 115 | * Get api key from captcha image |
||
| 116 | * |
||
| 117 | * @param array $data |
||
| 118 | * @return array($result, $info) |
||
| 119 | */ |
||
| 120 | public function postApiKey($data) |
||
| 132 | |||
| 133 | /** |
||
| 134 | * API post |
||
| 135 | * |
||
| 136 | * @param string $url |
||
| 137 | * @param array $data |
||
| 138 | * |
||
| 139 | * @return array($result, $info) |
||
| 140 | */ |
||
| 141 | public function postRequestApi($url, $data = array()) |
||
| 180 | |||
| 181 | /** |
||
| 182 | * API request processing |
||
| 183 | * |
||
| 184 | * @param string $url |
||
| 185 | * @param array $data |
||
| 186 | * |
||
| 187 | * @return array($result, $info) |
||
| 188 | */ |
||
| 189 | public function getRequestApi($url, $data = array()) |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Get message |
||
| 222 | * |
||
| 223 | * @param $info |
||
| 224 | * |
||
| 225 | * @return string |
||
| 226 | */ |
||
| 227 | View Code Duplication | public function getResponseErrorMessage($info) |
|
| 239 | } |
||
| 240 |
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.