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 |
||
| 17 | abstract class AbstractAdapterFactory implements FactoryInterface |
||
|
|
|||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var array |
||
| 21 | */ |
||
| 22 | protected $options; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * AbstractAdapterFactory constructor. |
||
| 26 | * |
||
| 27 | * @param array $options |
||
| 28 | */ |
||
| 29 | 58 | public function __construct(array $options = []) |
|
| 33 | |||
| 34 | /** |
||
| 35 | * Set creation options. |
||
| 36 | */ |
||
| 37 | 58 | public function setCreationOptions(array $options) |
|
| 41 | |||
| 42 | 10 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null): AdapterInterface |
|
| 56 | |||
| 57 | 2 | View Code Duplication | public function createService(ServiceLocatorInterface $serviceLocator): AdapterInterface |
| 65 | |||
| 66 | /** |
||
| 67 | * Merges the options given from the ServiceLocator Config object with the create options of the class. |
||
| 68 | */ |
||
| 69 | 13 | protected function mergeMvcConfig(ServiceLocatorInterface $serviceLocator, string $requestedName = null) |
|
| 84 | |||
| 85 | /** |
||
| 86 | * @throws InvalidArgumentException |
||
| 87 | */ |
||
| 88 | 1 | public function getLazyFactory(ServiceLocatorInterface $serviceLocator): LazyLoadingValueHolderFactory |
|
| 121 | |||
| 122 | /** |
||
| 123 | * Create service. |
||
| 124 | */ |
||
| 125 | abstract protected function doCreateService(ServiceLocatorInterface $serviceLocator): AdapterInterface; |
||
| 126 | |||
| 127 | /** |
||
| 128 | * Implement in adapter. |
||
| 129 | * |
||
| 130 | * @throw UnexpectedValueException |
||
| 131 | */ |
||
| 132 | abstract protected function validateConfig(); |
||
| 133 | } |
||
| 134 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.