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  | 
            ||
| 15 | final class Spreadsheet implements SpreadsheetInterface  | 
            ||
| 16 | { | 
            ||
| 17 | private $name;  | 
            ||
| 18 | private $sheets;  | 
            ||
| 19 | |||
| 20 | 14 | public function __construct(string $name)  | 
            |
| 25 | |||
| 26 | 11 | public function name(): string  | 
            |
| 30 | |||
| 31 | /**  | 
            ||
| 32 |      * {@inheritdoc} | 
            ||
| 33 | */  | 
            ||
| 34 | 9 | public function sheets(): MapInterface  | 
            |
| 38 | |||
| 39 | 11 | View Code Duplication | public function add(SheetInterface $sheet): SpreadsheetInterface  | 
            
| 53 | |||
| 54 | 2 | View Code Duplication | public function replace(SheetInterface $sheet): SpreadsheetInterface  | 
            
| 68 | |||
| 69 | 12 | public function has(string $sheet): bool  | 
            |
| 73 | |||
| 74 | 4 | public function get(string $sheet): SheetInterface  | 
            |
| 78 | }  | 
            ||
| 79 |