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:
Complex classes like GamecurrencyQuery often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use GamecurrencyQuery, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 89 | abstract class GamecurrencyQuery extends ModelCriteria |
||
| 90 | { |
||
| 91 | protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Initializes internal state of \eXpansion\Framework\PlayersBundle\Model\Base\GamecurrencyQuery object. |
||
| 95 | * |
||
| 96 | * @param string $dbName The database name |
||
| 97 | * @param string $modelName The phpName of a model, e.g. 'Book' |
||
| 98 | * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
||
| 99 | */ |
||
| 100 | public function __construct($dbName = 'expansion', $modelName = '\\eXpansion\\Framework\\PlayersBundle\\Model\\Gamecurrency', $modelAlias = null) |
||
| 104 | |||
| 105 | /** |
||
| 106 | * Returns a new ChildGamecurrencyQuery object. |
||
| 107 | * |
||
| 108 | * @param string $modelAlias The alias of a model in the query |
||
| 109 | * @param Criteria $criteria Optional Criteria to build the query from |
||
| 110 | * |
||
| 111 | * @return ChildGamecurrencyQuery |
||
| 112 | */ |
||
| 113 | public static function create($modelAlias = null, Criteria $criteria = null) |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Find object by primary key. |
||
| 131 | * Propel uses the instance pool to skip the database if the object exists. |
||
| 132 | * Go fast if the query is untouched. |
||
| 133 | * |
||
| 134 | * <code> |
||
| 135 | * $obj = $c->findPk(12, $con); |
||
| 136 | * </code> |
||
| 137 | * |
||
| 138 | * @param mixed $key Primary key to use for the query |
||
| 139 | * @param ConnectionInterface $con an optional connection object |
||
| 140 | * |
||
| 141 | * @return ChildGamecurrency|array|mixed the result, formatted by the current formatter |
||
| 142 | */ |
||
| 143 | public function findPk($key, ConnectionInterface $con = null) |
||
| 170 | |||
| 171 | /** |
||
| 172 | * Find object by primary key using raw SQL to go fast. |
||
| 173 | * Bypass doSelect() and the object formatter by using generated code. |
||
| 174 | * |
||
| 175 | * @param mixed $key Primary key to use for the query |
||
| 176 | * @param ConnectionInterface $con A connection object |
||
| 177 | * |
||
| 178 | * @throws \Propel\Runtime\Exception\PropelException |
||
| 179 | * |
||
| 180 | * @return ChildGamecurrency A model object, or null if the key is not found |
||
| 181 | */ |
||
| 182 | protected function findPkSimple($key, ConnectionInterface $con) |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Find object by primary key. |
||
| 207 | * |
||
| 208 | * @param mixed $key Primary key to use for the query |
||
| 209 | * @param ConnectionInterface $con A connection object |
||
| 210 | * |
||
| 211 | * @return ChildGamecurrency|array|mixed the result, formatted by the current formatter |
||
| 212 | */ |
||
| 213 | protected function findPkComplex($key, ConnectionInterface $con) |
||
| 223 | |||
| 224 | /** |
||
| 225 | * Find objects by primary key |
||
| 226 | * <code> |
||
| 227 | * $objs = $c->findPks(array(12, 56, 832), $con); |
||
| 228 | * </code> |
||
| 229 | * @param array $keys Primary keys to use for the query |
||
| 230 | * @param ConnectionInterface $con an optional connection object |
||
| 231 | * |
||
| 232 | * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
||
| 233 | */ |
||
| 234 | public function findPks($keys, ConnectionInterface $con = null) |
||
| 247 | |||
| 248 | /** |
||
| 249 | * Filter the query by primary key |
||
| 250 | * |
||
| 251 | * @param mixed $key Primary key to use for the query |
||
| 252 | * |
||
| 253 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 254 | */ |
||
| 255 | public function filterByPrimaryKey($key) |
||
| 260 | |||
| 261 | /** |
||
| 262 | * Filter the query by a list of primary keys |
||
| 263 | * |
||
| 264 | * @param array $keys The list of primary key to use for the query |
||
| 265 | * |
||
| 266 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 267 | */ |
||
| 268 | public function filterByPrimaryKeys($keys) |
||
| 273 | |||
| 274 | /** |
||
| 275 | * Filter the query on the id column |
||
| 276 | * |
||
| 277 | * Example usage: |
||
| 278 | * <code> |
||
| 279 | * $query->filterById(1234); // WHERE id = 1234 |
||
| 280 | * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
||
| 281 | * $query->filterById(array('min' => 12)); // WHERE id > 12 |
||
| 282 | * </code> |
||
| 283 | * |
||
| 284 | * @param mixed $id The value to use as filter. |
||
| 285 | * Use scalar values for equality. |
||
| 286 | * Use array values for in_array() equivalent. |
||
| 287 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 288 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 289 | * |
||
| 290 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 291 | */ |
||
| 292 | View Code Duplication | public function filterById($id = null, $comparison = null) |
|
| 314 | |||
| 315 | /** |
||
| 316 | * Filter the query on the senderLogin column |
||
| 317 | * |
||
| 318 | * Example usage: |
||
| 319 | * <code> |
||
| 320 | * $query->filterBySenderlogin('fooValue'); // WHERE senderLogin = 'fooValue' |
||
| 321 | * $query->filterBySenderlogin('%fooValue%', Criteria::LIKE); // WHERE senderLogin LIKE '%fooValue%' |
||
| 322 | * </code> |
||
| 323 | * |
||
| 324 | * @param string $senderlogin The value to use as filter. |
||
| 325 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 326 | * |
||
| 327 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 328 | */ |
||
| 329 | View Code Duplication | public function filterBySenderlogin($senderlogin = null, $comparison = null) |
|
| 339 | |||
| 340 | /** |
||
| 341 | * Filter the query on the receiverLogin column |
||
| 342 | * |
||
| 343 | * Example usage: |
||
| 344 | * <code> |
||
| 345 | * $query->filterByReceiverlogin('fooValue'); // WHERE receiverLogin = 'fooValue' |
||
| 346 | * $query->filterByReceiverlogin('%fooValue%', Criteria::LIKE); // WHERE receiverLogin LIKE '%fooValue%' |
||
| 347 | * </code> |
||
| 348 | * |
||
| 349 | * @param string $receiverlogin The value to use as filter. |
||
| 350 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 351 | * |
||
| 352 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 353 | */ |
||
| 354 | View Code Duplication | public function filterByReceiverlogin($receiverlogin = null, $comparison = null) |
|
| 364 | |||
| 365 | /** |
||
| 366 | * Filter the query on the transactionId column |
||
| 367 | * |
||
| 368 | * Example usage: |
||
| 369 | * <code> |
||
| 370 | * $query->filterByTransactionid(1234); // WHERE transactionId = 1234 |
||
| 371 | * $query->filterByTransactionid(array(12, 34)); // WHERE transactionId IN (12, 34) |
||
| 372 | * $query->filterByTransactionid(array('min' => 12)); // WHERE transactionId > 12 |
||
| 373 | * </code> |
||
| 374 | * |
||
| 375 | * @param mixed $transactionid The value to use as filter. |
||
| 376 | * Use scalar values for equality. |
||
| 377 | * Use array values for in_array() equivalent. |
||
| 378 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 379 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 380 | * |
||
| 381 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 382 | */ |
||
| 383 | View Code Duplication | public function filterByTransactionid($transactionid = null, $comparison = null) |
|
| 405 | |||
| 406 | /** |
||
| 407 | * Filter the query on the billId column |
||
| 408 | * |
||
| 409 | * Example usage: |
||
| 410 | * <code> |
||
| 411 | * $query->filterByBillid(1234); // WHERE billId = 1234 |
||
| 412 | * $query->filterByBillid(array(12, 34)); // WHERE billId IN (12, 34) |
||
| 413 | * $query->filterByBillid(array('min' => 12)); // WHERE billId > 12 |
||
| 414 | * </code> |
||
| 415 | * |
||
| 416 | * @param mixed $billid The value to use as filter. |
||
| 417 | * Use scalar values for equality. |
||
| 418 | * Use array values for in_array() equivalent. |
||
| 419 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 420 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 421 | * |
||
| 422 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 423 | */ |
||
| 424 | View Code Duplication | public function filterByBillid($billid = null, $comparison = null) |
|
| 446 | |||
| 447 | /** |
||
| 448 | * Filter the query on the amount column |
||
| 449 | * |
||
| 450 | * Example usage: |
||
| 451 | * <code> |
||
| 452 | * $query->filterByAmount(1234); // WHERE amount = 1234 |
||
| 453 | * $query->filterByAmount(array(12, 34)); // WHERE amount IN (12, 34) |
||
| 454 | * $query->filterByAmount(array('min' => 12)); // WHERE amount > 12 |
||
| 455 | * </code> |
||
| 456 | * |
||
| 457 | * @param mixed $amount The value to use as filter. |
||
| 458 | * Use scalar values for equality. |
||
| 459 | * Use array values for in_array() equivalent. |
||
| 460 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 461 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 462 | * |
||
| 463 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 464 | */ |
||
| 465 | View Code Duplication | public function filterByAmount($amount = null, $comparison = null) |
|
| 487 | |||
| 488 | /** |
||
| 489 | * Filter the query on the message column |
||
| 490 | * |
||
| 491 | * Example usage: |
||
| 492 | * <code> |
||
| 493 | * $query->filterByMessage('fooValue'); // WHERE message = 'fooValue' |
||
| 494 | * $query->filterByMessage('%fooValue%', Criteria::LIKE); // WHERE message LIKE '%fooValue%' |
||
| 495 | * </code> |
||
| 496 | * |
||
| 497 | * @param string $message The value to use as filter. |
||
| 498 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 499 | * |
||
| 500 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 501 | */ |
||
| 502 | View Code Duplication | public function filterByMessage($message = null, $comparison = null) |
|
| 512 | |||
| 513 | /** |
||
| 514 | * Filter the query on the status column |
||
| 515 | * |
||
| 516 | * Example usage: |
||
| 517 | * <code> |
||
| 518 | * $query->filterByStatus(1234); // WHERE status = 1234 |
||
| 519 | * $query->filterByStatus(array(12, 34)); // WHERE status IN (12, 34) |
||
| 520 | * $query->filterByStatus(array('min' => 12)); // WHERE status > 12 |
||
| 521 | * </code> |
||
| 522 | * |
||
| 523 | * @param mixed $status The value to use as filter. |
||
| 524 | * Use scalar values for equality. |
||
| 525 | * Use array values for in_array() equivalent. |
||
| 526 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 527 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 528 | * |
||
| 529 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 530 | */ |
||
| 531 | View Code Duplication | public function filterByStatus($status = null, $comparison = null) |
|
| 553 | |||
| 554 | /** |
||
| 555 | * Filter the query on the datetime column |
||
| 556 | * |
||
| 557 | * Example usage: |
||
| 558 | * <code> |
||
| 559 | * $query->filterByDatetime('2011-03-14'); // WHERE datetime = '2011-03-14' |
||
| 560 | * $query->filterByDatetime('now'); // WHERE datetime = '2011-03-14' |
||
| 561 | * $query->filterByDatetime(array('max' => 'yesterday')); // WHERE datetime > '2011-03-13' |
||
| 562 | * </code> |
||
| 563 | * |
||
| 564 | * @param mixed $datetime The value to use as filter. |
||
| 565 | * Values can be integers (unix timestamps), DateTime objects, or strings. |
||
| 566 | * Empty strings are treated as NULL. |
||
| 567 | * Use scalar values for equality. |
||
| 568 | * Use array values for in_array() equivalent. |
||
| 569 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 570 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 571 | * |
||
| 572 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 573 | */ |
||
| 574 | View Code Duplication | public function filterByDatetime($datetime = null, $comparison = null) |
|
| 596 | |||
| 597 | /** |
||
| 598 | * Exclude object from result |
||
| 599 | * |
||
| 600 | * @param ChildGamecurrency $gamecurrency Object to remove from the list of results |
||
| 601 | * |
||
| 602 | * @return $this|ChildGamecurrencyQuery The current query, for fluid interface |
||
| 603 | */ |
||
| 604 | public function prune($gamecurrency = null) |
||
| 612 | |||
| 613 | /** |
||
| 614 | * Deletes all rows from the gamecurrency table. |
||
| 615 | * |
||
| 616 | * @param ConnectionInterface $con the connection to use |
||
| 617 | * @return int The number of affected rows (if supported by underlying database driver). |
||
| 618 | */ |
||
| 619 | public function doDeleteAll(ConnectionInterface $con = null) |
||
| 639 | |||
| 640 | /** |
||
| 641 | * Performs a DELETE on the database based on the current ModelCriteria |
||
| 642 | * |
||
| 643 | * @param ConnectionInterface $con the connection to use |
||
| 644 | * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
||
| 645 | * if supported by native driver or if emulated using Propel. |
||
| 646 | * @throws PropelException Any exceptions caught during processing will be |
||
| 647 | * rethrown wrapped into a PropelException. |
||
| 648 | */ |
||
| 649 | public function delete(ConnectionInterface $con = null) |
||
| 673 | |||
| 674 | } // GamecurrencyQuery |
||
| 675 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: