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 |
||
| 13 | View Code Duplication | class ZipArchiveAdapterFactory extends AbstractAdapterFactory |
|
| 14 | { |
||
| 15 | public function doCreateService(ContainerInterface $container): AdapterInterface |
||
| 16 | { |
||
| 17 | if (! class_exists(\League\Flysystem\ZipArchive\ZipArchiveAdapter::class)) { |
||
| 18 | throw new RequirementsException( |
||
| 19 | ['league/ziparchive'], |
||
| 20 | 'ZipArchive' |
||
| 21 | ); |
||
| 22 | } |
||
| 23 | |||
| 24 | $adapter = new Adapter($this->options['archive'], null, $this->options['prefix']); |
||
| 25 | |||
| 26 | return $adapter; |
||
| 27 | } |
||
| 28 | |||
| 29 | 2 | protected function validateConfig() |
|
| 39 | } |
||
| 40 |