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 BannerImageI18nQuery 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 BannerImageI18nQuery, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 87 | abstract class BannerImageI18nQuery extends ModelCriteria |
||
| 88 | { |
||
| 89 | protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Initializes internal state of \xbanners\models\Base\BannerImageI18nQuery object. |
||
| 93 | * |
||
| 94 | * @param string $dbName The database name |
||
| 95 | * @param string $modelName The phpName of a model, e.g. 'Book' |
||
| 96 | * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
||
| 97 | */ |
||
| 98 | public function __construct($dbName = 'Shop', $modelName = '\\xbanners\\models\\BannerImageI18n', $modelAlias = null) |
||
| 102 | |||
| 103 | /** |
||
| 104 | * Returns a new ChildBannerImageI18nQuery object. |
||
| 105 | * |
||
| 106 | * @param string $modelAlias The alias of a model in the query |
||
| 107 | * @param Criteria $criteria Optional Criteria to build the query from |
||
| 108 | * |
||
| 109 | * @return ChildBannerImageI18nQuery |
||
| 110 | */ |
||
| 111 | View Code Duplication | public static function create($modelAlias = null, Criteria $criteria = null) |
|
| 126 | |||
| 127 | /** |
||
| 128 | * Find object by primary key. |
||
| 129 | * Propel uses the instance pool to skip the database if the object exists. |
||
| 130 | * Go fast if the query is untouched. |
||
| 131 | * |
||
| 132 | * <code> |
||
| 133 | * $obj = $c->findPk(array(12, 34), $con); |
||
| 134 | * </code> |
||
| 135 | * |
||
| 136 | * @param array[$id, $locale] $key Primary key to use for the query |
||
| 137 | * @param ConnectionInterface $con an optional connection object |
||
| 138 | * |
||
| 139 | * @return ChildBannerImageI18n|array|mixed the result, formatted by the current formatter |
||
| 140 | */ |
||
| 141 | public function findPk($key, ConnectionInterface $con = null) |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Find object by primary key using raw SQL to go fast. |
||
| 171 | * Bypass doSelect() and the object formatter by using generated code. |
||
| 172 | * |
||
| 173 | * @param mixed $key Primary key to use for the query |
||
| 174 | * @param ConnectionInterface $con A connection object |
||
| 175 | * |
||
| 176 | * @throws \Propel\Runtime\Exception\PropelException |
||
| 177 | * |
||
| 178 | * @return ChildBannerImageI18n A model object, or null if the key is not found |
||
| 179 | */ |
||
| 180 | View Code Duplication | protected function findPkSimple($key, ConnectionInterface $con) |
|
| 203 | |||
| 204 | /** |
||
| 205 | * Find object by primary key. |
||
| 206 | * |
||
| 207 | * @param mixed $key Primary key to use for the query |
||
| 208 | * @param ConnectionInterface $con A connection object |
||
| 209 | * |
||
| 210 | * @return ChildBannerImageI18n|array|mixed the result, formatted by the current formatter |
||
| 211 | */ |
||
| 212 | View Code Duplication | protected function findPkComplex($key, ConnectionInterface $con) |
|
| 222 | |||
| 223 | /** |
||
| 224 | * Find objects by primary key |
||
| 225 | * <code> |
||
| 226 | * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); |
||
| 227 | * </code> |
||
| 228 | * @param array $keys Primary keys to use for the query |
||
| 229 | * @param ConnectionInterface $con an optional connection object |
||
| 230 | * |
||
| 231 | * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
||
| 232 | */ |
||
| 233 | View Code Duplication | public function findPks($keys, ConnectionInterface $con = null) |
|
| 246 | |||
| 247 | /** |
||
| 248 | * Filter the query by primary key |
||
| 249 | * |
||
| 250 | * @param mixed $key Primary key to use for the query |
||
| 251 | * |
||
| 252 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 253 | */ |
||
| 254 | public function filterByPrimaryKey($key) |
||
| 261 | |||
| 262 | /** |
||
| 263 | * Filter the query by a list of primary keys |
||
| 264 | * |
||
| 265 | * @param array $keys The list of primary key to use for the query |
||
| 266 | * |
||
| 267 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 268 | */ |
||
| 269 | View Code Duplication | public function filterByPrimaryKeys($keys) |
|
| 283 | |||
| 284 | /** |
||
| 285 | * Filter the query on the id column |
||
| 286 | * |
||
| 287 | * Example usage: |
||
| 288 | * <code> |
||
| 289 | * $query->filterById(1234); // WHERE id = 1234 |
||
| 290 | * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
||
| 291 | * $query->filterById(array('min' => 12)); // WHERE id > 12 |
||
| 292 | * </code> |
||
| 293 | * |
||
| 294 | * @see filterByBannerImage() |
||
| 295 | * |
||
| 296 | * @param mixed $id The value to use as filter. |
||
| 297 | * Use scalar values for equality. |
||
| 298 | * Use array values for in_array() equivalent. |
||
| 299 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 300 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 301 | * |
||
| 302 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 303 | */ |
||
| 304 | View Code Duplication | public function filterById($id = null, $comparison = null) |
|
| 326 | |||
| 327 | /** |
||
| 328 | * Filter the query on the locale column |
||
| 329 | * |
||
| 330 | * Example usage: |
||
| 331 | * <code> |
||
| 332 | * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' |
||
| 333 | * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' |
||
| 334 | * </code> |
||
| 335 | * |
||
| 336 | * @param string $locale The value to use as filter. |
||
| 337 | * Accepts wildcards (* and % trigger a LIKE) |
||
| 338 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 339 | * |
||
| 340 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 341 | */ |
||
| 342 | View Code Duplication | public function filterByLocale($locale = null, $comparison = null) |
|
| 355 | |||
| 356 | /** |
||
| 357 | * Filter the query on the src column |
||
| 358 | * |
||
| 359 | * Example usage: |
||
| 360 | * <code> |
||
| 361 | * $query->filterBySrc('fooValue'); // WHERE src = 'fooValue' |
||
| 362 | * $query->filterBySrc('%fooValue%'); // WHERE src LIKE '%fooValue%' |
||
| 363 | * </code> |
||
| 364 | * |
||
| 365 | * @param string $src The value to use as filter. |
||
| 366 | * Accepts wildcards (* and % trigger a LIKE) |
||
| 367 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 368 | * |
||
| 369 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 370 | */ |
||
| 371 | View Code Duplication | public function filterBySrc($src = null, $comparison = null) |
|
| 384 | |||
| 385 | /** |
||
| 386 | * Filter the query on the name column |
||
| 387 | * |
||
| 388 | * Example usage: |
||
| 389 | * <code> |
||
| 390 | * $query->filterByName('fooValue'); // WHERE name = 'fooValue' |
||
| 391 | * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' |
||
| 392 | * </code> |
||
| 393 | * |
||
| 394 | * @param string $name The value to use as filter. |
||
| 395 | * Accepts wildcards (* and % trigger a LIKE) |
||
| 396 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 397 | * |
||
| 398 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 399 | */ |
||
| 400 | View Code Duplication | public function filterByName($name = null, $comparison = null) |
|
| 413 | |||
| 414 | /** |
||
| 415 | * Filter the query on the clicks column |
||
| 416 | * |
||
| 417 | * Example usage: |
||
| 418 | * <code> |
||
| 419 | * $query->filterByClicks(1234); // WHERE clicks = 1234 |
||
| 420 | * $query->filterByClicks(array(12, 34)); // WHERE clicks IN (12, 34) |
||
| 421 | * $query->filterByClicks(array('min' => 12)); // WHERE clicks > 12 |
||
| 422 | * </code> |
||
| 423 | * |
||
| 424 | * @param mixed $clicks The value to use as filter. |
||
| 425 | * Use scalar values for equality. |
||
| 426 | * Use array values for in_array() equivalent. |
||
| 427 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 428 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 429 | * |
||
| 430 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 431 | */ |
||
| 432 | View Code Duplication | public function filterByClicks($clicks = null, $comparison = null) |
|
| 454 | |||
| 455 | /** |
||
| 456 | * Filter the query on the description column |
||
| 457 | * |
||
| 458 | * Example usage: |
||
| 459 | * <code> |
||
| 460 | * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' |
||
| 461 | * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' |
||
| 462 | * </code> |
||
| 463 | * |
||
| 464 | * @param string $description The value to use as filter. |
||
| 465 | * Accepts wildcards (* and % trigger a LIKE) |
||
| 466 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 467 | * |
||
| 468 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 469 | */ |
||
| 470 | View Code Duplication | public function filterByDescription($description = null, $comparison = null) |
|
| 483 | |||
| 484 | /** |
||
| 485 | * Filter the query by a related \xbanners\models\BannerImage object |
||
| 486 | * |
||
| 487 | * @param \xbanners\models\BannerImage|ObjectCollection $bannerImage The related object(s) to use as filter |
||
| 488 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 489 | * |
||
| 490 | * @throws \Propel\Runtime\Exception\PropelException |
||
| 491 | * |
||
| 492 | * @return ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 493 | */ |
||
| 494 | View Code Duplication | public function filterByBannerImage($bannerImage, $comparison = null) |
|
| 510 | |||
| 511 | /** |
||
| 512 | * Adds a JOIN clause to the query using the BannerImage relation |
||
| 513 | * |
||
| 514 | * @param string $relationAlias optional alias for the relation |
||
| 515 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
||
| 516 | * |
||
| 517 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 518 | */ |
||
| 519 | View Code Duplication | public function joinBannerImage($relationAlias = null, $joinType = 'LEFT JOIN') |
|
| 542 | |||
| 543 | /** |
||
| 544 | * Use the BannerImage relation BannerImage object |
||
| 545 | * |
||
| 546 | * @see useQuery() |
||
| 547 | * |
||
| 548 | * @param string $relationAlias optional alias for the relation, |
||
| 549 | * to be used as main alias in the secondary query |
||
| 550 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
||
| 551 | * |
||
| 552 | * @return \xbanners\models\BannerImageQuery A secondary query class using the current class as primary query |
||
| 553 | */ |
||
| 554 | public function useBannerImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') |
||
| 560 | |||
| 561 | /** |
||
| 562 | * Exclude object from result |
||
| 563 | * |
||
| 564 | * @param ChildBannerImageI18n $bannerImageI18n Object to remove from the list of results |
||
| 565 | * |
||
| 566 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
| 567 | */ |
||
| 568 | View Code Duplication | public function prune($bannerImageI18n = null) |
|
| 578 | |||
| 579 | /** |
||
| 580 | * Deletes all rows from the banner_image_i18n table. |
||
| 581 | * |
||
| 582 | * @param ConnectionInterface $con the connection to use |
||
| 583 | * @return int The number of affected rows (if supported by underlying database driver). |
||
| 584 | */ |
||
| 585 | public function doDeleteAll(ConnectionInterface $con = null) |
||
| 605 | |||
| 606 | /** |
||
| 607 | * Performs a DELETE on the database based on the current ModelCriteria |
||
| 608 | * |
||
| 609 | * @param ConnectionInterface $con the connection to use |
||
| 610 | * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
||
| 611 | * if supported by native driver or if emulated using Propel. |
||
| 612 | * @throws PropelException Any exceptions caught during processing will be |
||
| 613 | * rethrown wrapped into a PropelException. |
||
| 614 | */ |
||
| 615 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 639 | |||
| 640 | } // BannerImageI18nQuery |
||
| 641 |