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 | class SftpAdapterFactory extends AbstractAdapterFactory |
||
| 14 | { |
||
| 15 | public function doCreateService(ContainerInterface $container): AdapterInterface |
||
| 16 | { |
||
| 17 | if (! class_exists(\League\Flysystem\Sftp\SftpAdapter::class)) { |
||
| 18 | throw new RequirementsException( |
||
| 19 | ['league/flysystem-sftp'], |
||
| 20 | 'Sftp' |
||
| 21 | ); |
||
| 22 | } |
||
| 23 | |||
| 24 | $adapter = new Adapter($this->options); |
||
| 25 | |||
| 26 | return $adapter; |
||
| 27 | } |
||
| 28 | |||
| 29 | 6 | View Code Duplication | protected function validateConfig() |
| 47 | } |
||
| 48 |