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 |
||
17 | class ContentProxy extends APIContent |
||
18 | { |
||
19 | use GeneratorProxyTrait; |
||
20 | |||
21 | /** |
||
22 | * @var \eZ\Publish\API\Repository\Values\Content\Content|null |
||
23 | */ |
||
24 | protected $object; |
||
25 | |||
26 | /** |
||
27 | * @var ContentContentInfoProxy|null |
||
28 | */ |
||
29 | protected $contentInfoProxy; |
||
30 | |||
31 | public function __get($name) |
||
47 | |||
48 | View Code Duplication | public function __isset($name) |
|
60 | |||
61 | /** |
||
62 | * Return content info, in proxy form if we have not loaded object yet. |
||
63 | * |
||
64 | * For usage in among others DomainMapper->buildLocation() to make sure we can lazy load content info retrieval. |
||
65 | * |
||
66 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
67 | */ |
||
68 | protected function getContentInfo() |
||
83 | |||
84 | public function getVersionInfo() |
||
92 | |||
93 | View Code Duplication | public function getFieldValue($fieldDefIdentifier, $languageCode = null) |
|
101 | |||
102 | public function getFields() |
||
110 | |||
111 | public function getFieldsByLanguage($languageCode = null) |
||
119 | |||
120 | View Code Duplication | public function getField($fieldDefIdentifier, $languageCode = null) |
|
128 | } |
||
129 |