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 |
||
| 2 | class MultiFormObjectDecoratorTest extends SapphireTest { |
||
|
|
|||
| 3 | |||
| 4 | protected static $fixture_file = 'MultiFormObjectDecoratorTest.yml'; |
||
| 5 | |||
| 6 | protected $requiredExtensions = array( |
||
| 7 | 'MultiFormObjectDecorator_DataObject' => array('MultiFormObjectDecorator') |
||
| 8 | ); |
||
| 9 | |||
| 10 | protected $extraDataObjects = array( |
||
| 11 | 'MultiFormObjectDecorator_DataObject' |
||
| 12 | ); |
||
| 13 | |||
| 14 | View Code Duplication | public function testTemporaryDataFilteredQuery() { |
|
| 24 | |||
| 25 | View Code Duplication | public function testTemporaryDataQuery() { |
|
| 35 | |||
| 36 | } |
||
| 37 | |||
| 45 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.