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 | * @param array $options |
||
| 32 | */ |
||
| 33 | public function __construct(array $options = []) |
||
| 55 | |||
| 56 | public function setLogger(LoggerInterface $logger) |
||
| 63 | |||
| 64 | |||
| 65 | /** |
||
| 66 | * @internal |
||
| 67 | * @return \GuzzleHttp\Event\Emitter|\GuzzleHttp\Event\EmitterInterface |
||
| 68 | */ |
||
| 69 | public function getEmitter() |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @param RequestInterface $request |
||
| 76 | * @return ResponseInterface |
||
| 77 | * @throws \Commercetools\Core\Error\ApiException |
||
| 78 | * @throws \Commercetools\Core\Error\BadGatewayException |
||
| 79 | * @throws \Commercetools\Core\Error\ConcurrentModificationException |
||
| 80 | * @throws \Commercetools\Core\Error\ErrorResponseException |
||
| 81 | * @throws \Commercetools\Core\Error\GatewayTimeoutException |
||
| 82 | * @throws \Commercetools\Core\Error\InternalServerErrorException |
||
| 83 | * @throws \Commercetools\Core\Error\InvalidTokenException |
||
| 84 | * @throws \Commercetools\Core\Error\NotFoundException |
||
| 85 | * @throws \Commercetools\Core\Error\ServiceUnavailableException |
||
| 86 | */ |
||
| 87 | public function execute(RequestInterface $request) |
||
| 105 | |||
| 106 | protected function packResponse(\GuzzleHttp\Message\ResponseInterface $response = null) |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @param RequestInterface[] $requests |
||
| 120 | * @return \Psr\Http\Message\ResponseInterface[] |
||
| 121 | * @throws \Commercetools\Core\Error\ApiException |
||
| 122 | * @throws \Commercetools\Core\Error\BadGatewayException |
||
| 123 | * @throws \Commercetools\Core\Error\ConcurrentModificationException |
||
| 124 | * @throws \Commercetools\Core\Error\ErrorResponseException |
||
| 125 | * @throws \Commercetools\Core\Error\GatewayTimeoutException |
||
| 126 | * @throws \Commercetools\Core\Error\InternalServerErrorException |
||
| 127 | * @throws \Commercetools\Core\Error\InvalidTokenException |
||
| 128 | * @throws \Commercetools\Core\Error\NotFoundException |
||
| 129 | * @throws \Commercetools\Core\Error\ServiceUnavailableException |
||
| 130 | */ |
||
| 131 | public function executeBatch(array $requests) |
||
| 152 | |||
| 153 | /** |
||
| 154 | * @return array |
||
| 155 | */ |
||
| 156 | protected function getBatchHttpRequests(array $requests) |
||
| 174 | |||
| 175 | /** |
||
| 176 | * @param $oauthUri |
||
| 177 | * @param $clientId |
||
| 178 | * @param $clientSecret |
||
| 179 | * @param $formParams |
||
| 180 | * @return ResponseInterface |
||
| 181 | */ |
||
| 182 | public function authenticate($oauthUri, $clientId, $clientSecret, $formParams) |
||
| 204 | |||
| 205 | /** |
||
| 206 | * @param RequestInterface $request |
||
| 207 | * @return AdapterPromiseInterface |
||
| 208 | */ |
||
| 209 | public function executeAsync(RequestInterface $request) |
||
| 234 | } |
||
| 235 |
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.