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 |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var ClientInterface |
||
| 18 | */ |
||
| 19 | private $httpClient; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var KvkPaginatorFactoryInterface |
||
| 23 | */ |
||
| 24 | private $profileResponseFactory; |
||
| 25 | |||
| 26 | 21 | public function __construct(ClientInterface $httpClient, KvkPaginatorFactoryInterface $profileResponseFactory) |
|
| 31 | |||
| 32 | 19 | public function getProfile(ProfileQuery $profileQuery): KvkPaginator |
|
| 39 | |||
| 40 | 1 | View Code Duplication | public function getNextPage(KvkPaginatorInterface $kvkPaginator): KvkPaginatorInterface |
| 47 | |||
| 48 | 1 | View Code Duplication | public function getPreviousPage(KvkPaginatorInterface $kvkPaginator): KvkPaginatorInterface |
| 55 | |||
| 56 | /** |
||
| 57 | * @param $json |
||
| 58 | * @return mixed |
||
| 59 | */ |
||
| 60 | 19 | private function decodeJsonToArray($json) |
|
| 64 | } |
||
| 65 |