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 |
||
| 24 | class DomainFactory |
||
| 25 | { |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
||
| 29 | * @param array $arguments [required] array of arguments to be passed to the Domain class |
||
| 30 | * constructor. Must at least include the following two value objects: |
||
| 31 | * array( |
||
| 32 | * EventEspresso\core\domain\values\FilePath $plugin_file |
||
| 33 | * EventEspresso\core\domain\values\Version $version |
||
| 34 | * ) |
||
| 35 | * @return mixed |
||
| 36 | * @throws DomainException |
||
| 37 | * @throws InvalidArgumentException |
||
| 38 | * @throws InvalidDataTypeException |
||
| 39 | * @throws InvalidInterfaceException |
||
| 40 | */ |
||
| 41 | public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
||
| 65 | |||
| 66 | } |
||
| 67 | |||
| 71 |