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 | class TaskRepository extends EntityRepository implements TaskRepositoryInterface |
||
|
|||
22 | { |
||
23 | /** |
||
24 | * {@inheritdoc} |
||
25 | */ |
||
26 | 9 | public function create($handlerClass, $workload = null) |
|
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public function findByUuid($uuid) |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | 9 | public function save(TaskInterface $task) |
|
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | 1 | public function remove(TaskInterface $task) |
|
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 5 | View Code Duplication | public function findAll($page = 1, $pageSize = null) |
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | 2 | public function findEndBeforeNow() |
|
84 | |||
85 | /** |
||
86 | * Returns task where last-execution is before given date-time. |
||
87 | * |
||
88 | * @param \DateTime $dateTime |
||
89 | * |
||
90 | * @return TaskInterface[] |
||
91 | */ |
||
92 | 2 | public function findEndBefore(\DateTime $dateTime) |
|
100 | } |
||
101 |