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 |
||
| 34 | class StructureDefinitionHierarchy |
||
| 35 | { |
||
| 36 | /** |
||
| 37 | * @var array $nodes The array holding the different structure definitions |
||
| 38 | */ |
||
| 39 | protected $nodes = array(); |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Will insert a structure definition into our hierarchy |
||
| 43 | * |
||
| 44 | * @param \AppserverIo\Doppelgaenger\Interfaces\StructureDefinitionInterface $node The structure definition to insert |
||
| 45 | * |
||
| 46 | * @return bool |
||
| 47 | */ |
||
| 48 | public function insert(StructureDefinitionInterface $node) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Will return an entry specified by it's name |
||
| 76 | * |
||
| 77 | * @param string $entryName Name of the entries we search for |
||
| 78 | * |
||
| 79 | * @return bool |
||
| 80 | */ |
||
| 81 | View Code Duplication | public function getEntry($entryName) |
|
| 89 | |||
| 90 | /** |
||
| 91 | * Check if a certain entry exists |
||
| 92 | * |
||
| 93 | * @param string $entryName Name of the entries we search for |
||
| 94 | * |
||
| 95 | * @return bool |
||
| 96 | */ |
||
| 97 | View Code Duplication | public function entryExists($entryName) |
|
| 106 | |||
| 107 | /** |
||
| 108 | * Will return true if all possible node entries contain data |
||
| 109 | * |
||
| 110 | * @return bool |
||
| 111 | */ |
||
| 112 | public function isComplete() |
||
| 122 | } |
||
| 123 |