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 |
||
10 | class Override implements Buildable, Delay |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $name; |
||
16 | |||
17 | /** |
||
18 | * @var callable |
||
19 | */ |
||
20 | protected $callback; |
||
21 | |||
22 | /** |
||
23 | * @var ClassMetadataBuilder |
||
24 | */ |
||
25 | protected $builder; |
||
26 | |||
27 | /** |
||
28 | * @var NamingStrategy |
||
29 | */ |
||
30 | protected $namingStrategy; |
||
31 | |||
32 | /** |
||
33 | * @param ClassMetadataBuilder $builder |
||
34 | * @param NamingStrategy $namingStrategy |
||
35 | * @param string $name |
||
36 | * @param callable $callback |
||
37 | */ |
||
38 | 5 | View Code Duplication | public function __construct(ClassMetadataBuilder $builder, NamingStrategy $namingStrategy, $name, callable $callback) |
45 | |||
46 | /** |
||
47 | * Execute the build process |
||
48 | */ |
||
49 | 5 | public function build() |
|
60 | } |
||
61 |