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 declare(strict_types=1); |
||
8 | View Code Duplication | final class SimpleRequestCommand implements RequestCommandInterface |
|
9 | { |
||
10 | /** |
||
11 | * @var RequestInterface |
||
12 | */ |
||
13 | private $request; |
||
14 | |||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | private $options; |
||
19 | |||
20 | /** |
||
21 | * @var bool |
||
22 | */ |
||
23 | private $refresh; |
||
24 | |||
25 | /** |
||
26 | * @param string $path |
||
27 | * @param bool $refresh |
||
28 | * @param array $options |
||
29 | */ |
||
30 | public function __construct(string $path, array $options = [], bool $refresh = false) |
||
39 | |||
40 | /** |
||
41 | * @return RequestInterface |
||
42 | */ |
||
43 | public function getRequest(): RequestInterface |
||
47 | |||
48 | /** |
||
49 | * @return array |
||
50 | */ |
||
51 | public function getOptions(): array |
||
55 | |||
56 | /** |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function getRefresh(): bool |
||
63 | } |
||
64 |