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 |
||
19 | View Code Duplication | final class QueryParamHandler extends AbstractParameterHandler |
|
20 | { |
||
21 | /** |
||
22 | * @var StringConverter |
||
23 | */ |
||
24 | private $converter; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $name; |
||
30 | |||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | private $encoded; |
||
35 | |||
36 | /** |
||
37 | * Constructor |
||
38 | * |
||
39 | * @param string $name |
||
40 | * @param StringConverter $converter |
||
41 | * @param bool $encoded |
||
42 | */ |
||
43 | 9 | public function __construct(StringConverter $converter, string $name, bool $encoded) |
|
49 | |||
50 | /** |
||
51 | * Set a value to the [@see RequestBuilder] for parameter type |
||
52 | * |
||
53 | * @param RequestBuilder $requestBuilder |
||
54 | * @param mixed $value |
||
55 | * @return void |
||
56 | * @throws \RuntimeException |
||
57 | */ |
||
58 | 7 | public function apply(RequestBuilder $requestBuilder, $value): void |
|
68 | } |
||
69 |