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 | 39 | public function __construct(ClientInterface $httpClient, KvkPaginatorFactoryInterface $profileResponseFactory) |
|
| 31 | |||
| 32 | 21 | View Code Duplication | public function getProfile(QueryInterface $profileQuery): KvkPaginatorInterface |
| 39 | |||
| 40 | /** |
||
| 41 | * Execute search query |
||
| 42 | * @author Patrick Development <[email protected]> |
||
| 43 | */ |
||
| 44 | 16 | View Code Duplication | public function fetchSearch(QueryInterface $profileQuery): KvkPaginatorInterface |
| 51 | |||
| 52 | 1 | View Code Duplication | public function getNextPage(KvkPaginatorInterface $kvkPaginator): KvkPaginatorInterface |
| 59 | |||
| 60 | 1 | View Code Duplication | public function getPreviousPage(KvkPaginatorInterface $kvkPaginator): KvkPaginatorInterface |
| 67 | |||
| 68 | 37 | private function decodeJsonToArray(string $json): array |
|
| 88 | } |
||
| 89 |