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 |
||
| 35 | class Union extends StatementAbstract implements UnionStatementInterface |
||
| 36 | { |
||
| 37 | use ClauseTrait, OrderTrait, LimitTrait; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param BuilderInterface $builder |
||
| 41 | * @access public |
||
| 42 | */ |
||
| 43 | public function __construct(BuilderInterface $builder) |
||
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritDoc} |
||
| 50 | */ |
||
| 51 | public function union(SelectStatementInterface $select) |
||
| 55 | |||
| 56 | /** |
||
| 57 | * {@inheritDoc} |
||
| 58 | */ |
||
| 59 | public function unionAll(SelectStatementInterface $select) |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Build unioned SELECT |
||
| 66 | * |
||
| 67 | * @param string $prefix |
||
| 68 | * @param array $settings |
||
| 69 | * @return string |
||
| 70 | * @access protected |
||
| 71 | */ |
||
| 72 | View Code Duplication | protected function buildUnion( |
|
| 88 | |||
| 89 | /** |
||
| 90 | * @param string $type |
||
| 91 | * @param SelectStatementInterface $select |
||
| 92 | * @return $this |
||
| 93 | * @access protected |
||
| 94 | */ |
||
| 95 | protected function addUnion( |
||
| 103 | |||
| 104 | /** |
||
| 105 | * {@inheritDoc} |
||
| 106 | */ |
||
| 107 | protected function getConfigs()/*# : array */ |
||
| 115 | |||
| 116 | /** |
||
| 117 | * {@inheritDoc} |
||
| 118 | */ |
||
| 119 | protected function getType()/*# : string */ |
||
| 123 | } |
||
| 124 |