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 PhpunitController extends \hidev\controllers\CommonController |
||
21 | { |
||
22 | protected $_before = ['phpunit.xml.dist']; |
||
23 | |||
24 | public $force; |
||
25 | public $colors; |
||
26 | public $coverageText; |
||
27 | public $coverageClover; |
||
28 | |||
29 | public function getConfiguration() |
||
33 | |||
34 | public function actionMake() |
||
38 | |||
39 | public function actionRun() |
||
54 | |||
55 | View Code Duplication | public function actionGenfake($file) |
|
65 | |||
66 | public function genFake($file, $path) |
||
75 | |||
76 | View Code Duplication | public function actionGentest($file) |
|
86 | |||
87 | public function genSkel($file) |
||
94 | |||
95 | public function buildNamespace($dir = '') |
||
99 | |||
100 | public function buildTestNamespace($dir = 'tests\\unit') |
||
104 | |||
105 | public function buildClass($file, $dir = '') |
||
109 | |||
110 | public function buildTestClass($file, $dir = 'tests\\unit') |
||
114 | |||
115 | public function buildPath($file, $dir = 'src', $prefix = '', $postfix = '') |
||
119 | |||
120 | public function buildTestPath($file, $dir = 'tests/unit', $prefix = '', $postfix = 'Test') |
||
124 | |||
125 | public function buildFakePath($file, $dir = 'tests/unit', $prefix = 'Fake', $postfix = '') |
||
129 | } |
||
130 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.