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 |
||
5 | class DefaultNamingStrategyTest extends \PHPUnit_Framework_TestCase |
||
6 | { |
||
7 | public function testGetBeanName() |
||
18 | |||
19 | public function testGetBaseBeanName() |
||
26 | |||
27 | View Code Duplication | public function testGetDaoName() |
|
|
|||
28 | { |
||
29 | $strategy = new DefaultNamingStrategy(); |
||
30 | $strategy->setDaoPrefix(''); |
||
31 | $strategy->setDaoSuffix('Dao'); |
||
32 | $this->assertSame('UserDao', $strategy->getDaoClassName("users")); |
||
33 | } |
||
34 | |||
35 | public function testGetBaseDaoName() |
||
42 | |||
43 | public function testGetBeanNameDefault() |
||
49 | |||
50 | public function testGetBaseBeanNameDefault() |
||
55 | |||
56 | public function testGetDaoNameDefault() |
||
61 | |||
62 | public function testGetBaseDaoNameDefault() |
||
67 | |||
68 | public function testGetDaoFactory() |
||
73 | |||
74 | public function testExceptions() |
||
82 | |||
83 | View Code Duplication | public function testUppercaseNames() |
|
90 | } |
||
91 |
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.