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 |
||
21 | View Code Duplication | class ResolverChain |
|
22 | { |
||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | private $resolvers; |
||
27 | |||
28 | /** |
||
29 | * Constructor |
||
30 | */ |
||
31 | public function __construct() |
||
35 | |||
36 | /** |
||
37 | * Add a resolver |
||
38 | * |
||
39 | * @param \Jb\Bundle\FileUploaderBundle\Service\Resolver\ResolverInterface $resolver |
||
40 | */ |
||
41 | public function addResolver(ResolverInterface $resolver, $alias) |
||
45 | |||
46 | /** |
||
47 | * |
||
48 | * @param string $alias |
||
49 | * |
||
50 | * @return \Jb\Bundle\FileUploaderBundle\Service\Resolver\ResolverInterface |
||
51 | * |
||
52 | * @throws \Jb\Bundle\FileUploaderBundle\Exception\JbFileUploaderException |
||
53 | */ |
||
54 | public function getResolver($alias) |
||
62 | } |
||
63 |