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 AssetManifestFactory implements FactoryInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var AssetManifestInterface[] |
||
21 | */ |
||
22 | private static $manifests = []; |
||
23 | |||
24 | /** |
||
25 | * @var LoaderInterface $loader |
||
26 | */ |
||
27 | protected $loader; |
||
28 | |||
29 | |||
30 | /** |
||
31 | * AssetManifestFactory constructor. |
||
32 | * |
||
33 | * @param LoaderInterface $loader |
||
34 | */ |
||
35 | public function __construct(LoaderInterface $loader) |
||
39 | |||
40 | |||
41 | /** |
||
42 | * returns the applicable AssetManifest for the provided Domain |
||
43 | * |
||
44 | * @param DomainInterface $domain |
||
45 | * @return AssetManifestInterface |
||
46 | */ |
||
47 | public function createFromDomainObject(DomainInterface $domain) |
||
51 | |||
52 | |||
53 | /** |
||
54 | * for creating an atypical AssetManifest for the Domain provided in the $arguments array |
||
55 | * |
||
56 | * @param string $fqcn Fully Qualified Class Name |
||
57 | * @param array $arguments [optional] array of data required for construction |
||
58 | * @return AssetManifestInterface |
||
59 | */ |
||
60 | public function create($fqcn, array $arguments = []) |
||
72 | |||
73 | |||
74 | /** |
||
75 | * @param string $manifest_fqcn |
||
76 | * @param DomainInterface $domain |
||
77 | * @return AssetManifestInterface |
||
78 | */ |
||
79 | private function getAssetManifestForDomain($manifest_fqcn, DomainInterface $domain) |
||
101 | } |
||
102 |