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 |
||
24 | View Code Duplication | class BlockMatcherFactory extends BaseFactory implements SiteAccessAware, ContainerAwareInterface |
|
25 | { |
||
26 | /** |
||
27 | * @var \Symfony\Component\DependencyInjection\ContainerInterface |
||
28 | */ |
||
29 | private $container; |
||
30 | |||
31 | /** |
||
32 | * @var \eZ\Publish\Core\MVC\ConfigResolverInterface; |
||
33 | */ |
||
34 | private $configResolver; |
||
35 | |||
36 | public function __construct(ConfigResolverInterface $configResolver, Repository $repository) |
||
37 | { |
||
38 | @trigger_error( |
||
39 | "BlockMatcherFactory is deprecated, and will be removed in ezpublish-kernel 6.1.\n" . |
||
40 | 'Use the ServiceAwareMatcherFactory with the relative namespace as a constructor argument.', |
||
41 | E_USER_DEPRECATED |
||
42 | ); |
||
43 | |||
44 | $this->configResolver = $configResolver; |
||
45 | parent::__construct( |
||
46 | $repository, |
||
47 | $this->configResolver->getParameter('block_view') |
||
48 | ); |
||
49 | } |
||
50 | |||
51 | public function setContainer(ContainerInterface $container = null) |
||
55 | |||
56 | /** |
||
57 | * @param string $matcherIdentifier |
||
58 | * |
||
59 | * @return \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MatcherInterface |
||
60 | */ |
||
61 | protected function getMatcher($matcherIdentifier) |
||
69 | |||
70 | /** |
||
71 | * Changes internal configuration to use the one for passed SiteAccess. |
||
72 | * |
||
73 | * @param SiteAccess $siteAccess |
||
74 | */ |
||
75 | public function setSiteAccess(SiteAccess $siteAccess = null) |
||
83 | } |
||
84 |
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.