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 RulerTest extends TestCase  | 
            ||
| 21 | { | 
            ||
| 22 | /**  | 
            ||
| 23 | * @expectedException \Sensorario\Resources\Exceptions\UndefinedResourceException  | 
            ||
| 24 | * @expectedExceptionMessage Oops! Cant get rule without resource  | 
            ||
| 25 | */  | 
            ||
| 26 | public function testCantGetRuleWithoutRecource()  | 
            ||
| 27 |     { | 
            ||
| 28 | $ruler = new Ruler();  | 
            ||
| 29 | $ruler->getRuleFromResource();  | 
            ||
| 30 | }  | 
            ||
| 31 | }  | 
            ||
| 32 |