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 QueryNameParamHandler extends AbstractParameterHandler | |
| 20 | { | ||
| 21 | /** | ||
| 22 | * @var StringConverter | ||
| 23 | */ | ||
| 24 | private $converter; | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @var bool | ||
| 28 | */ | ||
| 29 | private $encoded; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Constructor | ||
| 33 | * | ||
| 34 | * @param StringConverter $converter | ||
| 35 | * @param bool $encoded | ||
| 36 | */ | ||
| 37 | 5 | public function __construct(StringConverter $converter, bool $encoded) | |
| 42 | |||
| 43 | /** | ||
| 44 | * Set a value to the [@see RequestBuilder] for parameter type | ||
| 45 | * | ||
| 46 | * @param RequestBuilder $requestBuilder | ||
| 47 | * @param mixed $value | ||
| 48 | * @return void | ||
| 49 | * @throws \RuntimeException | ||
| 50 | */ | ||
| 51 | 4 | public function apply(RequestBuilder $requestBuilder, $value): void | |
| 61 | } | ||
| 62 |