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 Guzzle5Adapter implements AdapterInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var Client |
||
23 | */ |
||
24 | protected $client; |
||
25 | |||
26 | /** |
||
27 | * @var LoggerInterface |
||
28 | */ |
||
29 | protected $logger; |
||
30 | |||
31 | /** |
||
32 | * @param array $options |
||
33 | */ |
||
34 | public function __construct(array $options = []) |
||
56 | |||
57 | public function setLogger(LoggerInterface $logger) |
||
64 | |||
65 | public function addHandler($handler) |
||
69 | |||
70 | /** |
||
71 | * @internal |
||
72 | * @return \GuzzleHttp\Event\Emitter|\GuzzleHttp\Event\EmitterInterface |
||
73 | */ |
||
74 | public function getEmitter() |
||
78 | |||
79 | /** |
||
80 | * @param RequestInterface $request |
||
81 | * @return ResponseInterface |
||
82 | * @throws \Commercetools\Core\Error\ApiException |
||
83 | * @throws \Commercetools\Core\Error\BadGatewayException |
||
84 | * @throws \Commercetools\Core\Error\ConcurrentModificationException |
||
85 | * @throws \Commercetools\Core\Error\ErrorResponseException |
||
86 | * @throws \Commercetools\Core\Error\GatewayTimeoutException |
||
87 | * @throws \Commercetools\Core\Error\InternalServerErrorException |
||
88 | * @throws \Commercetools\Core\Error\InvalidTokenException |
||
89 | * @throws \Commercetools\Core\Error\NotFoundException |
||
90 | * @throws \Commercetools\Core\Error\ServiceUnavailableException |
||
91 | */ |
||
92 | public function execute(RequestInterface $request) |
||
110 | |||
111 | protected function packResponse(\GuzzleHttp\Message\ResponseInterface $response = null) |
||
122 | |||
123 | /** |
||
124 | * @param RequestInterface[] $requests |
||
125 | * @return \Psr\Http\Message\ResponseInterface[] |
||
126 | * @throws \Commercetools\Core\Error\ApiException |
||
127 | * @throws \Commercetools\Core\Error\BadGatewayException |
||
128 | * @throws \Commercetools\Core\Error\ConcurrentModificationException |
||
129 | * @throws \Commercetools\Core\Error\ErrorResponseException |
||
130 | * @throws \Commercetools\Core\Error\GatewayTimeoutException |
||
131 | * @throws \Commercetools\Core\Error\InternalServerErrorException |
||
132 | * @throws \Commercetools\Core\Error\InvalidTokenException |
||
133 | * @throws \Commercetools\Core\Error\NotFoundException |
||
134 | * @throws \Commercetools\Core\Error\ServiceUnavailableException |
||
135 | */ |
||
136 | public function executeBatch(array $requests) |
||
157 | |||
158 | /** |
||
159 | * @return array |
||
160 | */ |
||
161 | protected function getBatchHttpRequests(array $requests) |
||
179 | |||
180 | /** |
||
181 | * @param $oauthUri |
||
182 | * @param $clientId |
||
183 | * @param $clientSecret |
||
184 | * @param $formParams |
||
185 | * @return ResponseInterface |
||
186 | */ |
||
187 | public function authenticate($oauthUri, $clientId, $clientSecret, $formParams) |
||
209 | |||
210 | /** |
||
211 | * @param RequestInterface $request |
||
212 | * @return AdapterPromiseInterface |
||
213 | */ |
||
214 | public function executeAsync(RequestInterface $request) |
||
239 | } |
||
240 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.