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  | 
            ||
| 9 | class CommandCreator extends Creator  | 
            ||
| 10 | { | 
            ||
| 11 | /**  | 
            ||
| 12 | * Create a new command with given name.  | 
            ||
| 13 | *  | 
            ||
| 14 | * @param string $name  | 
            ||
| 15 | *  | 
            ||
| 16 | * @throws WriteError  | 
            ||
| 17 | *  | 
            ||
| 18 | * @return string  | 
            ||
| 19 | */  | 
            ||
| 20 | public function create($name)  | 
            ||
| 38 | |||
| 39 | /**  | 
            ||
| 40 | * Get the stub file and insert name.  | 
            ||
| 41 | *  | 
            ||
| 42 | * @param string $name  | 
            ||
| 43 | *  | 
            ||
| 44 | * @return string  | 
            ||
| 45 | */  | 
            ||
| 46 | View Code Duplication | protected function getStub($name)  | 
            |
| 57 | }  | 
            ||
| 58 |