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 |
||
21 | View Code Duplication | class EnumCollection extends Collection |
|
22 | { |
||
23 | const COLLECTION_NAME = 'espresso_graphql_enums'; |
||
24 | |||
25 | /** |
||
26 | * @var CollectionLoader $loader |
||
27 | */ |
||
28 | protected $loader; |
||
29 | |||
30 | /** |
||
31 | * EnumCollection constructor |
||
32 | * |
||
33 | * @throws InvalidInterfaceException |
||
34 | */ |
||
35 | public function __construct() |
||
42 | |||
43 | |||
44 | /** |
||
45 | * @throws CollectionDetailsException |
||
46 | * @throws CollectionLoaderException |
||
47 | * @since $VID:$ |
||
48 | */ |
||
49 | private function loadCollection() |
||
75 | |||
76 | |||
77 | /** |
||
78 | * @return CollectionInterface |
||
79 | * @throws CollectionDetailsException |
||
80 | * @throws CollectionLoaderException |
||
81 | * @since $VID:$ |
||
82 | */ |
||
83 | public function loadEnums() |
||
88 | |||
89 | |||
90 | /** |
||
91 | * getIdentifier |
||
92 | * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
||
93 | * If no $identifier is supplied, then the fully qualified class name is used |
||
94 | * |
||
95 | * @param $object |
||
96 | * @param mixed $identifier |
||
97 | * @return bool |
||
98 | */ |
||
99 | public function getIdentifier($object, $identifier = null) |
||
105 | } |
||
106 |