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 | class TaskExecutionRepository extends EntityRepository implements TaskExecutionRepositoryInterface |
||
|
|
|||
| 25 | { |
||
| 26 | /** |
||
| 27 | * {@inheritdoc} |
||
| 28 | */ |
||
| 29 | 9 | public function create(TaskInterface $task, \DateTime $scheduleTime) |
|
| 33 | |||
| 34 | /** |
||
| 35 | * {@inheritdoc} |
||
| 36 | */ |
||
| 37 | 9 | public function save(TaskExecutionInterface $execution) |
|
| 38 | { |
||
| 39 | 9 | $this->_em->persist($execution); |
|
| 40 | |||
| 41 | 9 | return $this; |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc} |
||
| 46 | */ |
||
| 47 | public function remove(TaskExecutionInterface $execution) |
||
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritdoc} |
||
| 56 | */ |
||
| 57 | 9 | View Code Duplication | public function findAll($page = 1, $pageSize = null) |
| 70 | 6 | ||
| 71 | 6 | /** |
|
| 72 | * {@inheritdoc} |
||
| 73 | 6 | */ |
|
| 74 | 3 | public function findByStartTime(TaskInterface $task, \DateTime $scheduleTime) |
|
| 89 | 7 | ||
| 90 | 7 | /** |
|
| 91 | 7 | * {@inheritdoc} |
|
| 92 | 7 | */ |
|
| 93 | 7 | public function findByTask(TaskInterface $task) |
|
| 102 | |||
| 103 | /** |
||
| 104 | * {@inheritdoc} |
||
| 105 | */ |
||
| 106 | public function findScheduled(\DateTime $dateTime = null) |
||
| 120 | } |
||
| 121 |