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 |
||
| 18 | class MappedSuperClassMetadataBinder |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var Mapping\ClassMetadataBuildingContext |
||
| 22 | */ |
||
| 23 | private $metadataBuildingContext; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var \ReflectionClass |
||
| 27 | */ |
||
| 28 | private $reflectionClass; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * [dreaming] One day we would eliminate this and only do: $reflectionClass->getAnnotations() |
||
| 32 | * |
||
| 33 | * @var array<string, object> |
||
| 34 | */ |
||
| 35 | private $classAnnotations; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @todo guilhermeblanco This should disappear once we instantiation happens in the Driver |
||
| 39 | * |
||
| 40 | * @var Mapping\ClassMetadata |
||
| 41 | */ |
||
| 42 | private $classMetadata; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * ComponentMetadataBinder constructor. |
||
| 46 | * |
||
| 47 | * @param \ReflectionClass $reflectionClass |
||
| 48 | * @param array<string, object> $classAnnotations |
||
| 49 | * @param Mapping\ClassMetadata $classMetadata |
||
| 50 | * @param Mapping\ClassMetadataBuildingContext $metadataBuildingContext |
||
| 51 | */ |
||
| 52 | View Code Duplication | public function __construct( |
|
| 64 | |||
| 65 | /** |
||
| 66 | * @return Mapping\ClassMetadata |
||
| 67 | * |
||
| 68 | * @throws Mapping\MappingException |
||
| 69 | */ |
||
| 70 | public function bind() : Mapping\ClassMetadata |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param Mapping\ClassMetadata $classMetadata |
||
| 81 | * @param Annotation\MappedSuperclass $mappedSuperclassAnnotation |
||
| 82 | * |
||
| 83 | * @return void |
||
| 84 | */ |
||
| 85 | private function processMappedSuperclassAnnotation( |
||
| 99 | } |
||
| 100 |