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 |
||
19 | View Code Duplication | class CacheFactory implements FactoryInterface |
|
20 | { |
||
21 | |||
22 | /** |
||
23 | * Create service |
||
24 | * |
||
25 | * @param ServiceLocatorInterface $serviceLocator |
||
26 | * @return StorageInterface |
||
27 | */ |
||
28 | public function createService(ServiceLocatorInterface $serviceLocator) |
||
32 | |||
33 | /** |
||
34 | * Create an object |
||
35 | * |
||
36 | * @param ContainerInterface $container |
||
37 | * @param string $requestedName |
||
38 | * @param null|array $options |
||
39 | * @return StorageInterface |
||
40 | * @throws \Zend\Cache\Exception\InvalidArgumentException |
||
41 | * @throws \Interop\Container\Exception\NotFoundException |
||
42 | * @throws ServiceNotFoundException if unable to resolve the service. |
||
43 | * @throws ServiceNotCreatedException if an exception is raised when |
||
44 | * creating a service. |
||
45 | * @throws ContainerException if any other error occurs |
||
46 | */ |
||
47 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
||
51 | |||
52 | /** |
||
53 | * @param ServiceLocatorInterface|ContainerInterface $container |
||
54 | * @return StorageInterface |
||
55 | */ |
||
56 | protected function create($container) |
||
66 | } |
||
67 |
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.