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 |
||
11 | class AssetsViewComposer |
||
12 | { |
||
13 | /** |
||
14 | * @var AssetManager |
||
15 | */ |
||
16 | protected $assetManager; |
||
17 | /** |
||
18 | * @var AssetPipeline |
||
19 | */ |
||
20 | protected $assetPipeline; |
||
21 | /** |
||
22 | * @var AssetTypeFactory |
||
23 | */ |
||
24 | protected $assetFactory; |
||
25 | /** |
||
26 | * @var Request |
||
27 | */ |
||
28 | private $request; |
||
29 | |||
30 | public function __construct(AssetManager $assetManager, AssetPipeline $assetPipeline, AssetTypeFactory $assetTypeFactory, Request $request) |
||
37 | |||
38 | public function compose(View $view) |
||
47 | |||
48 | View Code Duplication | private function onBackend() |
|
57 | } |
||
58 |