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 |
||
| 34 | class QueryException extends \Doctrine\ORM\ORMException |
||
| 35 | { |
||
| 36 | /** |
||
| 37 | * @param string $dql |
||
| 38 | * |
||
| 39 | * @return QueryException |
||
| 40 | */ |
||
| 41 | 52 | public static function dqlError($dql) |
|
| 45 | |||
| 46 | /** |
||
| 47 | * @param string $message |
||
| 48 | * @param \Exception|null $previous |
||
| 49 | * |
||
| 50 | * @return QueryException |
||
| 51 | */ |
||
| 52 | 18 | public static function syntaxError($message, $previous = null) |
|
| 56 | |||
| 57 | /** |
||
| 58 | * @param string $message |
||
| 59 | * @param \Exception|null $previous |
||
| 60 | * |
||
| 61 | * @return QueryException |
||
| 62 | */ |
||
| 63 | 35 | public static function semanticalError($message, $previous = null) |
|
| 67 | |||
| 68 | /** |
||
| 69 | * @return QueryException |
||
| 70 | */ |
||
| 71 | public static function invalidLockMode() |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param string $expected |
||
| 78 | * @param string $received |
||
| 79 | * |
||
| 80 | * @return QueryException |
||
| 81 | */ |
||
| 82 | public static function invalidParameterType($expected, $received) |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @param string $pos |
||
| 89 | * |
||
| 90 | * @return QueryException |
||
| 91 | */ |
||
| 92 | public static function invalidParameterPosition($pos) |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @param integer $expected |
||
| 99 | * @param integer $received |
||
| 100 | * |
||
| 101 | * @return QueryException |
||
| 102 | */ |
||
| 103 | 1 | public static function tooManyParameters($expected, $received) |
|
| 107 | |||
| 108 | /** |
||
| 109 | * @param integer $expected |
||
| 110 | * @param integer $received |
||
| 111 | * |
||
| 112 | * @return QueryException |
||
| 113 | */ |
||
| 114 | 1 | public static function tooFewParameters($expected, $received) |
|
| 118 | |||
| 119 | /** |
||
| 120 | * @param string $value |
||
| 121 | * |
||
| 122 | * @return QueryException |
||
| 123 | */ |
||
| 124 | 2 | public static function invalidParameterFormat($value) |
|
| 128 | |||
| 129 | /** |
||
| 130 | * @param string $key |
||
| 131 | * |
||
| 132 | * @return QueryException |
||
| 133 | */ |
||
| 134 | 1 | public static function unknownParameter($key) |
|
| 138 | |||
| 139 | /** |
||
| 140 | * @return QueryException |
||
| 141 | */ |
||
| 142 | public static function parameterTypeMismatch() |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @param object $pathExpr |
||
| 149 | * |
||
| 150 | * @return QueryException |
||
| 151 | */ |
||
| 152 | public static function invalidPathExpression($pathExpr) |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @param string $literal |
||
| 161 | * |
||
| 162 | * @return QueryException |
||
| 163 | */ |
||
| 164 | public static function invalidLiteral($literal) |
||
| 168 | |||
| 169 | /** |
||
| 170 | * @param array $assoc |
||
| 171 | * |
||
| 172 | * @return QueryException |
||
| 173 | */ |
||
| 174 | View Code Duplication | public static function iterateWithFetchJoinCollectionNotAllowed($assoc) |
|
| 181 | |||
| 182 | /** |
||
| 183 | * @return QueryException |
||
| 184 | */ |
||
| 185 | public static function partialObjectsAreDangerous() |
||
| 193 | |||
| 194 | /** |
||
| 195 | * @param array $assoc |
||
| 196 | * |
||
| 197 | * @return QueryException |
||
| 198 | */ |
||
| 199 | public static function overwritingJoinConditionsNotYetSupported($assoc) |
||
| 207 | |||
| 208 | /** |
||
| 209 | * @param PathExpression $pathExpr |
||
| 210 | * |
||
| 211 | * @return QueryException |
||
| 212 | */ |
||
| 213 | 2 | public static function associationPathInverseSideNotSupported(PathExpression $pathExpr) |
|
| 220 | |||
| 221 | /** |
||
| 222 | * @param array $assoc |
||
| 223 | * |
||
| 224 | * @return QueryException |
||
| 225 | */ |
||
| 226 | 2 | View Code Duplication | public static function iterateWithFetchJoinNotAllowed($assoc) |
| 233 | |||
| 234 | /** |
||
| 235 | * @return QueryException |
||
| 236 | */ |
||
| 237 | 1 | public static function associationPathCompositeKeyNotSupported() |
|
| 245 | |||
| 246 | /** |
||
| 247 | * @param string $className |
||
| 248 | * @param string $rootClass |
||
| 249 | * |
||
| 250 | * @return QueryException |
||
| 251 | */ |
||
| 252 | 1 | public static function instanceOfUnrelatedClass($className, $rootClass) |
|
| 257 | |||
| 258 | /** |
||
| 259 | * @param string $dqlAlias |
||
| 260 | * |
||
| 261 | * @return QueryException |
||
| 262 | */ |
||
| 263 | 1 | public static function invalidQueryComponent($dqlAlias) |
|
| 270 | } |
||
| 271 |