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 |
||
| 14 | View Code Duplication | class WebDAVAdapterFactory extends AbstractAdapterFactory |
|
| 15 | { |
||
| 16 | public function doCreateService(ContainerInterface $container): AdapterInterface |
||
| 17 | { |
||
| 18 | if (! class_exists(\League\Flysystem\WebDAV\WebDAVAdapter::class)) { |
||
| 19 | throw new RequirementsException( |
||
| 20 | ['league/flysystem-webdav'], |
||
| 21 | 'WebDAV' |
||
| 22 | ); |
||
| 23 | } |
||
| 24 | |||
| 25 | $client = new Client($this->options); |
||
| 26 | |||
| 27 | $adapter = new Adapter($client, $this->options['prefix']); |
||
| 28 | |||
| 29 | return $adapter; |
||
| 30 | } |
||
| 31 | |||
| 32 | 2 | protected function validateConfig() |
|
| 42 | } |
||
| 43 |