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 | class FetchPlan extends AbstractFetchPlan |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * @var string The relative link for fetching a certain plan |
||
21 | */ |
||
22 | const FETCH_PLAN_LINK = '/plan/:identifier'; |
||
23 | |||
24 | /** |
||
25 | * @var string Paystack's base Url |
||
26 | */ |
||
27 | protected $baseUrl; |
||
28 | |||
29 | 2 | public function __construct(string $baseUrl) |
|
33 | |||
34 | /** |
||
35 | * @param string $planIdentifier The unique plan identifier |
||
36 | * @return mixed |
||
37 | * @throws \Gbowo\Exception\InvalidHttpResponseException if ann http response of 200 isn't returned |
||
38 | */ |
||
39 | 2 | View Code Duplication | public function handle(string $planIdentifier) |
57 | } |
||
58 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.