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 DiAbstractPluginFactory implements AbstractFactoryInterface |
||
| 14 | { |
||
| 15 | /** @var DiAbstractFactory */ |
||
| 16 | protected $factory; |
||
| 17 | |||
| 18 | 2 | public function __construct(DiAbstractFactory $factory = null) |
|
| 22 | |||
| 23 | /** |
||
| 24 | * Determine if we can create a service with name |
||
| 25 | * |
||
| 26 | * @param ServiceLocatorInterface $serviceLocator |
||
| 27 | * @param string $name |
||
| 28 | * @param string $requestedName |
||
| 29 | * @return bool |
||
| 30 | */ |
||
| 31 | 1 | View Code Duplication | public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) |
| 39 | |||
| 40 | /** |
||
| 41 | * Create service with name |
||
| 42 | * |
||
| 43 | * @param ServiceLocatorInterface $serviceLocator |
||
| 44 | * @param string $name |
||
| 45 | * @param string $requestedName |
||
| 46 | * @return object |
||
| 47 | */ |
||
| 48 | 1 | View Code Duplication | public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) |
| 56 | } |
||
| 57 |