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 namespace Modules\Core\Composers; |
||
8 | class ApplicationVersionViewComposer |
||
9 | { |
||
10 | /** |
||
11 | * @var Filesystem |
||
12 | */ |
||
13 | private $filesystem; |
||
14 | /** |
||
15 | * @var Repository |
||
16 | */ |
||
17 | private $cache; |
||
18 | /** |
||
19 | * @var Request |
||
20 | */ |
||
21 | private $request; |
||
22 | |||
23 | public function __construct(Filesystem $filesystem, Repository $cache, Request $request) |
||
29 | |||
30 | public function compose(View $view) |
||
37 | |||
38 | View Code Duplication | private function onBackend() |
|
46 | |||
47 | /** |
||
48 | * @return string |
||
49 | */ |
||
50 | private function getAppVersion() |
||
56 | |||
57 | /** |
||
58 | * Get the decoded contents from the main composer.json file |
||
59 | * @return object |
||
60 | */ |
||
61 | private function getComposerFile() |
||
69 | } |
||
70 |