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 |
||
| 12 | class JSONTextIntegrationTest extends SapphireTest |
||
|
|
|||
| 13 | { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected static $fixture_file = '/tests/fixtures/yml/MyAwesomeJSONModel.yml'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Modifies fixtures property to be able to run on PHP <5.6 without use of constant in class property which 5.6+ allows |
||
| 22 | */ |
||
| 23 | public function __construct() |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Tests JSONText::setValue() by means of a simple JSONPath expression operating on a nested JSON array |
||
| 30 | * on a saved DataObject record. |
||
| 31 | */ |
||
| 32 | View Code Duplication | public function testSetValueOnNestedArray() |
|
| 56 | |||
| 57 | /** |
||
| 58 | * Tests JSONText::setValue() by means of a simple JSONPath expression operating on a simple, un-nested JSON array |
||
| 59 | * on a saved DataObject record. |
||
| 60 | */ |
||
| 61 | View Code Duplication | public function testSetValueOnUnNestedArray() |
|
| 85 | |||
| 86 | } |
||
| 87 | |||
| 96 | } |
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.