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 |
||
22 | class PluginApiService |
||
23 | { |
||
24 | /** |
||
25 | * Url for Api |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | private $apiUrl; |
||
30 | |||
31 | /** |
||
32 | * @var EccubeConfig |
||
33 | */ |
||
34 | private $eccubeConfig; |
||
35 | |||
36 | /** |
||
37 | * @var RequestStack |
||
38 | */ |
||
39 | private $requestStack; |
||
40 | |||
41 | /** |
||
42 | * @var BaseInfo |
||
43 | */ |
||
44 | private $BaseInfo; |
||
45 | |||
46 | /** |
||
47 | * PluginApiService constructor. |
||
48 | * |
||
49 | * @param EccubeConfig $eccubeConfig |
||
50 | * @param RequestStack $requestStack |
||
51 | * @param BaseInfoRepository $baseInfoRepository |
||
52 | * @throws \Doctrine\ORM\NoResultException |
||
53 | * @throws \Doctrine\ORM\NonUniqueResultException |
||
54 | */ |
||
55 | public function __construct(EccubeConfig $eccubeConfig, RequestStack $requestStack, BaseInfoRepository $baseInfoRepository) |
||
61 | |||
62 | /** |
||
63 | * @return mixed |
||
64 | */ |
||
65 | public function getApiUrl() |
||
73 | |||
74 | /** |
||
75 | * @param mixed $apiUrl |
||
76 | */ |
||
77 | public function setApiUrl($apiUrl) |
||
81 | |||
82 | /** |
||
83 | * Get master data: category |
||
84 | * |
||
85 | * @return array($result, $info) |
||
|
|||
86 | */ |
||
87 | public function getCategory() |
||
93 | |||
94 | /** |
||
95 | * Get plugins list |
||
96 | * |
||
97 | * @param array $data |
||
98 | * |
||
99 | * @return array($result, $info) |
||
100 | */ |
||
101 | public function getPlugins($data) |
||
113 | |||
114 | /** |
||
115 | * Get purchased plugins list |
||
116 | * |
||
117 | * @return array($result, $info) |
||
118 | */ |
||
119 | public function getPurchased() |
||
124 | |||
125 | /** |
||
126 | * Get a plugin |
||
127 | * |
||
128 | * @param int|string $id Id or plugin code |
||
129 | * |
||
130 | * @return array [$result, $info] |
||
131 | */ |
||
132 | public function getPlugin($id) |
||
138 | |||
139 | /** |
||
140 | * Get captcha image |
||
141 | * |
||
142 | * @return array($result, $info) |
||
143 | */ |
||
144 | public function getCaptcha() |
||
152 | |||
153 | /** |
||
154 | * Get api key from captcha image |
||
155 | * |
||
156 | * @param array $data |
||
157 | * |
||
158 | * @return array($result, $info) |
||
159 | */ |
||
160 | public function postApiKey($data) |
||
172 | |||
173 | /** |
||
174 | * API post |
||
175 | * |
||
176 | * @param string $url |
||
177 | * @param array $data |
||
178 | * |
||
179 | * @return array($result, $info) |
||
180 | */ |
||
181 | public function postRequestApi($url, $data = []) |
||
220 | |||
221 | /** |
||
222 | * API request processing |
||
223 | * |
||
224 | * @param string $url |
||
225 | * @param array $data |
||
226 | * |
||
227 | * @return array($result, $info) |
||
228 | */ |
||
229 | public function getRequestApi($url, $data = []) |
||
267 | |||
268 | /** |
||
269 | * Get message |
||
270 | * |
||
271 | * @param $info |
||
272 | * |
||
273 | * @return string |
||
274 | */ |
||
275 | View Code Duplication | public function getResponseErrorMessage($info) |
|
287 | } |
||
288 |
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.