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 |
||
| 12 | View Code Duplication | final class UriFactoryDiscovery extends FactoryDiscovery |
|
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var UriFactory |
||
| 16 | */ |
||
| 17 | protected static $cache; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var array |
||
| 21 | */ |
||
| 22 | protected static $classes = [ |
||
| 23 | 'guzzle' => [ |
||
| 24 | 'class' => 'Http\Message\UriFactory\GuzzleUriFactory', |
||
| 25 | 'condition' => [ |
||
| 26 | 'Http\Message\UriFactory\GuzzleUriFactory', |
||
| 27 | 'GuzzleHttp\Psr7\Uri', |
||
| 28 | ], |
||
| 29 | ], |
||
| 30 | 'diactoros' => [ |
||
| 31 | 'class' => 'Http\Message\UriFactory\DiactorosUriFactory', |
||
| 32 | 'condition' => [ |
||
| 33 | 'Http\Message\UriFactory\DiactorosUriFactory', |
||
| 34 | 'Zend\Diactoros\Uri', |
||
| 35 | ], |
||
| 36 | ], |
||
| 37 | ]; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Finds a URI Factory. |
||
| 41 | * |
||
| 42 | * @return UriFactory |
||
| 43 | */ |
||
| 44 | 1 | public static function find() |
|
| 49 | } |
||
| 50 |