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 |
||
20 | class AssetCollection extends Collection |
||
21 | { |
||
22 | |||
23 | |||
24 | /** |
||
25 | * AssetCollection constructor |
||
26 | * |
||
27 | * @throws InvalidInterfaceException |
||
28 | */ |
||
29 | public function __construct() |
||
33 | |||
34 | |||
35 | /** |
||
36 | * @return StylesheetAsset[] |
||
37 | * @since $VID:$ |
||
38 | */ |
||
39 | public function getStylesheetAssets() |
||
43 | |||
44 | |||
45 | /** |
||
46 | * @return JavascriptAsset[] |
||
47 | * @since $VID:$ |
||
48 | */ |
||
49 | public function getJavascriptAssets() |
||
53 | |||
54 | |||
55 | /** |
||
56 | * @return ManifestFile[] |
||
57 | * @since $VID:$ |
||
58 | */ |
||
59 | public function getManifestFiles() |
||
63 | |||
64 | |||
65 | /** |
||
66 | * @param $type |
||
67 | * @return array |
||
68 | * @since $VID:$ |
||
69 | */ |
||
70 | View Code Duplication | protected function getAssetsOfType($type) |
|
85 | |||
86 | |||
87 | /** |
||
88 | * @return JavascriptAsset[] |
||
89 | * @since $VID:$ |
||
90 | */ |
||
91 | View Code Duplication | public function getJavascriptAssetsWithData() |
|
106 | } |
||
107 |