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 |
||
17 | class Guzzle5ApiClient extends ApiClient implements ApiClientInterface |
||
18 | { |
||
19 | /** |
||
20 | * Guzzle5 Client implementation for making HTTP requests with |
||
21 | * the appropriate options. |
||
22 | * |
||
23 | * @param string $method |
||
24 | * @param string $uri |
||
25 | * @param array $options |
||
26 | * |
||
27 | * @return \GuzzleHttp\Message\ResponseInterface |
||
28 | */ |
||
29 | protected function _doRequest($method, $uri, $options) |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | * |
||
44 | * @param ResponseInterface $response |
||
45 | * |
||
46 | * @return string |
||
47 | */ |
||
48 | View Code Duplication | protected function serializeResponse($response) |
|
62 | |||
63 | /** |
||
64 | * Unserializes the serialized response into a ResponseInterface instance. |
||
65 | * |
||
66 | * @param string $serialized |
||
67 | * |
||
68 | * @return ResponseInterface |
||
69 | * |
||
70 | * @throws Exception |
||
71 | */ |
||
72 | protected function unserializeResponse($serialized) |
||
81 | } |
||
82 |
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.