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  | 
            ||
| 11 | abstract class AbstractTest extends SapphireTest  | 
            ||
| 12 | { | 
            ||
| 13 | protected $usesDatabase = true;  | 
            ||
| 14 | |||
| 15 | protected function setUp()  | 
            ||
| 16 |     { | 
            ||
| 17 | parent::setUp();  | 
            ||
| 18 | |||
| 19 | TestCookieStore::$override_headers_sent = false;  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 20 | |||
| 21 | Injector::inst()->registerService(  | 
            ||
| 22 | new TestCookieStore(),  | 
            ||
| 23 | CookieStore::class  | 
            ||
| 24 | );  | 
            ||
| 25 | |||
| 26 |         DBDatetime::set_mock_now('2010-03-15 12:00:00'); | 
            ||
| 27 | }  | 
            ||
| 28 | |||
| 29 | protected function tearDown()  | 
            ||
| 30 |     { | 
            ||
| 31 | DBDatetime::clear_mock_now();  | 
            ||
| 32 | |||
| 33 | parent::tearDown();  | 
            ||
| 34 | }  | 
            ||
| 35 | |||
| 36 | abstract protected function getStore();  | 
            ||
| 37 | |||
| 38 | /**  | 
            ||
| 39 | * Test how this store handles large volumes of data (>1000 characters)  | 
            ||
| 40 | */  | 
            ||
| 41 | View Code Duplication | public function testStoreLargeData()  | 
            |
| 59 | |||
| 60 | /**  | 
            ||
| 61 | * Test storage of data  | 
            ||
| 62 | */  | 
            ||
| 63 | public function testStoreData()  | 
            ||
| 90 | |||
| 91 | /**  | 
            ||
| 92 | * Test expiry of data  | 
            ||
| 93 | */  | 
            ||
| 94 | public function testExpiry()  | 
            ||
| 113 | }  | 
            ||
| 114 | 
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.