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 |
||
16 | final class KvkClient implements KvkClientInterface, KvkPaginatorAwareInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var ClientInterface |
||
20 | */ |
||
21 | private $httpClient; |
||
22 | |||
23 | /** |
||
24 | * @var KvkPaginatorFactoryInterface |
||
25 | */ |
||
26 | private $profileResponseFactory; |
||
27 | |||
28 | 23 | public function __construct(ClientInterface $httpClient, KvkPaginatorFactoryInterface $profileResponseFactory) |
|
33 | |||
34 | 21 | View Code Duplication | public function getProfile(QueryInterface $profileQuery): KvkPaginatorInterface |
41 | |||
42 | /** |
||
43 | * Execute search query |
||
44 | * @param QueryInterface $profileQuery |
||
45 | * @return KvkPaginatorInterface |
||
46 | * @throws KvkApiException |
||
47 | * @author Patrick Development <[email protected]> |
||
48 | */ |
||
49 | View Code Duplication | public function getSearch(QueryInterface $profileQuery): KvkPaginatorInterface |
|
56 | |||
57 | 1 | View Code Duplication | public function getNextPage(KvkPaginatorInterface $kvkPaginator): KvkPaginatorInterface |
64 | |||
65 | 1 | View Code Duplication | public function getPreviousPage(KvkPaginatorInterface $kvkPaginator): KvkPaginatorInterface |
72 | |||
73 | 21 | private function decodeJsonToArray(string $json): array |
|
93 | } |
||
94 |