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 |
||
22 | View Code Duplication | class ListTrails implements ServiceInterface |
|
23 | { |
||
24 | /** |
||
25 | * @var AbstractTrailRepository |
||
26 | */ |
||
27 | private $trailRepository; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $filters; |
||
33 | |||
34 | /** |
||
35 | * @var LoggerInterface |
||
36 | */ |
||
37 | private $logger; |
||
38 | |||
39 | /** |
||
40 | * ListTrails constructor. |
||
41 | * @param AbstractTrailRepository $trailRepository |
||
42 | * @param array $filters |
||
43 | * @param LoggerInterface $logger |
||
44 | */ |
||
45 | 2 | public function __construct(AbstractTrailRepository $trailRepository, Array $filters, LoggerInterface $logger) |
|
51 | |||
52 | /** |
||
53 | * @return array|stdClass[] |
||
54 | */ |
||
55 | 2 | public function run(): array |
|
65 | } |
||
66 |