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 |
||
9 | class WidgetMapChildrenResolver |
||
|
|||
10 | { |
||
11 | private $logger; |
||
12 | |||
13 | /** |
||
14 | * WidgetMapChildrenResolver constructor. |
||
15 | * |
||
16 | * @param Logger $logger |
||
17 | */ |
||
18 | public function __construct(Logger $logger) |
||
22 | |||
23 | /** |
||
24 | * Return "after" and "before" children, |
||
25 | * based on contextual View and its Templates. |
||
26 | * |
||
27 | * @return array |
||
28 | */ |
||
29 | public function getChildren(WidgetMap $widgetMap, View $view = null) |
||
73 | |||
74 | /** |
||
75 | * @param $position |
||
76 | * @param View|null $view |
||
77 | * |
||
78 | * @return bool |
||
79 | */ |
||
80 | public function hasChildren(WidgetMap $widgetMap, $position, View $view = null) |
||
90 | } |
||
91 |