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 | class PageFacet implements FacetInterface |
||
| 23 | { |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $name; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | protected $label; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @var bool |
||
| 37 | */ |
||
| 38 | protected $canModifyMatcher = false; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Constructor of a Generic Facet in Vidi. |
||
| 42 | * |
||
| 43 | * @param string $label |
||
| 44 | */ |
||
| 45 | public function __construct($label = '') |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | public function getName() |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | public function getLabel() |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @return array |
||
| 75 | */ |
||
| 76 | public function getSuggestions() |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @return array |
||
| 89 | */ |
||
| 90 | protected function getStoragePages() |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Returns a pointer to the database. |
||
| 109 | * |
||
| 110 | * @return \TYPO3\CMS\Core\Database\DatabaseConnection |
||
| 111 | */ |
||
| 112 | protected function getDatabaseConnection() |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @return LanguageService |
||
| 119 | */ |
||
| 120 | View Code Duplication | protected function getLanguageService() |
|
| 132 | |||
| 133 | /** |
||
| 134 | * @return bool |
||
| 135 | */ |
||
| 136 | public function hasSuggestions() |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @param string $dataType |
||
| 143 | * @return $this |
||
| 144 | */ |
||
| 145 | public function setDataType($dataType) |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @return bool |
||
| 153 | */ |
||
| 154 | public function canModifyMatcher() |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @param Matcher $matcher |
||
| 161 | * @param $value |
||
| 162 | * @return Matcher |
||
| 163 | */ |
||
| 164 | public function modifyMatcher(Matcher $matcher, $value) |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Get the Vidi Module Loader. |
||
| 171 | * |
||
| 172 | * @return ModuleLoader|object |
||
| 173 | * @throws \InvalidArgumentException |
||
| 174 | */ |
||
| 175 | protected function getModuleLoader() |
||
| 179 | |||
| 180 | /** |
||
| 181 | * Magic method implementation for retrieving state. |
||
| 182 | * |
||
| 183 | * @param array $states |
||
| 184 | * @return PageFacet |
||
| 185 | */ |
||
| 186 | static public function __set_state($states) |
||
| 190 | |||
| 191 | } |
||
| 192 |