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 BodyParamHandler extends AbstractParameterHandler | |
| 20 | { | ||
| 21 | /** | ||
| 22 | * @var RequestBodyConverter | ||
| 23 | */ | ||
| 24 | private $converter; | ||
| 25 | |||
| 26 | /** | ||
| 27 | * Constructor | ||
| 28 | * | ||
| 29 | * @param RequestBodyConverter $converter | ||
| 30 | */ | ||
| 31 | 11 | public function __construct(RequestBodyConverter $converter) | |
| 35 | |||
| 36 | /** | ||
| 37 | * Converts the value to a stream, then sets the body to the request builder | ||
| 38 | * | ||
| 39 | * @param RequestBuilder $requestBuilder | ||
| 40 | * @param mixed $value | ||
| 41 | * @return void | ||
| 42 | */ | ||
| 43 | 4 | public function apply(RequestBuilder $requestBuilder, $value): void | |
| 51 | } | ||
| 52 |