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 |
||
| 7 | class FileCache implements CacheInterface |
||
| 8 | { |
||
| 9 | private $dir; |
||
| 10 | |||
| 11 | public function __construct($dir) |
||
| 22 | |||
| 23 | /** |
||
| 24 | * {@inheritDoc} |
||
| 25 | */ |
||
| 26 | View Code Duplication | public function loadClassMetadataFromCache(\ReflectionClass $class) |
|
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritDoc} |
||
| 38 | */ |
||
| 39 | public function putClassMetadataInCache(ClassMetadata $metadata) |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Renames a file with fallback for windows |
||
| 54 | * |
||
| 55 | * @param string $source |
||
| 56 | * @param string $target |
||
| 57 | */ |
||
| 58 | private function renameFile($source, $target) { |
||
| 72 | |||
| 73 | /** |
||
| 74 | * {@inheritDoc} |
||
| 75 | */ |
||
| 76 | View Code Duplication | public function evictClassMetadataFromCache(\ReflectionClass $class) |
|
| 83 | } |
||
| 84 |