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 |
||
16 | class WidgetBusinessUnitSelectConverter extends ConfigValueConverterAbstract |
||
17 | { |
||
18 | /** @var EntityRepository */ |
||
19 | protected $businessUnitRepository; |
||
20 | |||
21 | /** @var SecurityFacade */ |
||
22 | protected $securityFacade; |
||
23 | |||
24 | /** @var BusinessUnitAclProvider */ |
||
25 | protected $businessUnitAclProvider; |
||
26 | |||
27 | /** |
||
28 | * @param EntityRepository $businessUnitRepository |
||
29 | * @param SecurityFacade $securityFacade |
||
30 | * @param BusinessUnitAclProvider $businessUnitAclProvider |
||
31 | */ |
||
32 | public function __construct( |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | View Code Duplication | public function getConvertedValue(array $widgetConfig, $value = null, array $config = [], array $options = []) |
|
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public function getFormValue(array $converterAttributes, $value) |
||
65 | |||
66 | /** |
||
67 | * @param mixed $value |
||
68 | * @return mixed |
||
69 | */ |
||
70 | public function getViewValue($value) |
||
74 | |||
75 | /** |
||
76 | * @param array $config |
||
77 | * @return array |
||
78 | */ |
||
79 | public function getBusinessUnitList($config) |
||
103 | |||
104 | /** |
||
105 | * @param QueryBuilder $queryBuilder |
||
106 | * @param array $businessUnitIds |
||
107 | * @param string $accessLevel |
||
108 | */ |
||
109 | protected function applyAdditionalConditions(QueryBuilder $queryBuilder, $businessUnitIds, $accessLevel) |
||
113 | } |
||
114 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.