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 |
||
14 | final class KvkClient implements KvkClientInterface, KvkPaginatorAwareInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var ClientInterface |
||
18 | */ |
||
19 | private $httpClient; |
||
20 | |||
21 | /** |
||
22 | * @var KvkPaginatorFactoryInterface |
||
23 | */ |
||
24 | private $profileResponseFactory; |
||
25 | |||
26 | 23 | public function __construct(ClientInterface $httpClient, KvkPaginatorFactoryInterface $profileResponseFactory) |
|
31 | |||
32 | 21 | View Code Duplication | public function getProfile(QueryInterface $profileQuery): KvkPaginatorInterface |
39 | |||
40 | 1 | /** |
|
41 | * Execute search query |
||
42 | 1 | * @author Patrick Development <[email protected]> |
|
43 | 1 | */ |
|
44 | View Code Duplication | public function fetchSearch(QueryInterface $profileQuery): KvkPaginatorInterface |
|
51 | 1 | ||
52 | View Code Duplication | public function getNextPage(KvkPaginatorInterface $kvkPaginator): KvkPaginatorInterface |
|
59 | |||
60 | 21 | View Code Duplication | public function getPreviousPage(KvkPaginatorInterface $kvkPaginator): KvkPaginatorInterface |
67 | 20 | ||
68 | 1 | private function decodeJsonToArray(string $json): array |
|
88 | } |
||
89 |