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 |
||
13 | class FormParamLocation extends AbstractLocation |
||
14 | { |
||
15 | /** @var string $contentType */ |
||
16 | protected $contentType = 'application/x-www-form-urlencoded; charset=utf-8'; |
||
17 | |||
18 | /** @var array $formParamsData */ |
||
19 | protected $formParamsData = []; |
||
20 | |||
21 | /** |
||
22 | * Set the name of the location |
||
23 | * |
||
24 | * @param string $locationName |
||
25 | */ |
||
26 | 2 | public function __construct($locationName = 'formParam') |
|
30 | |||
31 | /** |
||
32 | * @param CommandInterface $command |
||
33 | * @param RequestInterface $request |
||
34 | * @param Parameter $param |
||
35 | * |
||
36 | * @return RequestInterface |
||
37 | */ |
||
38 | 2 | public function visit( |
|
50 | |||
51 | /** |
||
52 | * @param CommandInterface $command |
||
53 | * @param RequestInterface $request |
||
54 | * @param Operation $operation |
||
55 | * |
||
56 | * @return RequestInterface |
||
57 | */ |
||
58 | 2 | public function after( |
|
84 | } |
||
85 |