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