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 | View Code Duplication | public function findPk($key, ConnectionInterface $con = null)  | 
            |
| 162 | |||
| 163 | /**  | 
            ||
| 164 | * Find object by primary key using raw SQL to go fast.  | 
            ||
| 165 | * Bypass doSelect() and the object formatter by using generated code.  | 
            ||
| 166 | *  | 
            ||
| 167 | * @param mixed $key Primary key to use for the query  | 
            ||
| 168 | * @param ConnectionInterface $con A connection object  | 
            ||
| 169 | *  | 
            ||
| 170 | * @throws \Propel\Runtime\Exception\PropelException  | 
            ||
| 171 | *  | 
            ||
| 172 | * @return ChildBannerImageI18n A model object, or null if the key is not found  | 
            ||
| 173 | */  | 
            ||
| 174 | View Code Duplication | protected function findPkSimple($key, ConnectionInterface $con)  | 
            |
| 197 | |||
| 198 | /**  | 
            ||
| 199 | * Find object by primary key.  | 
            ||
| 200 | *  | 
            ||
| 201 | * @param mixed $key Primary key to use for the query  | 
            ||
| 202 | * @param ConnectionInterface $con A connection object  | 
            ||
| 203 | *  | 
            ||
| 204 | * @return ChildBannerImageI18n|array|mixed the result, formatted by the current formatter  | 
            ||
| 205 | */  | 
            ||
| 206 | View Code Duplication | protected function findPkComplex($key, ConnectionInterface $con)  | 
            |
| 216 | |||
| 217 | /**  | 
            ||
| 218 | * Find objects by primary key  | 
            ||
| 219 | * <code>  | 
            ||
| 220 | * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);  | 
            ||
| 221 | * </code>  | 
            ||
| 222 | * @param array $keys Primary keys to use for the query  | 
            ||
| 223 | * @param ConnectionInterface $con an optional connection object  | 
            ||
| 224 | *  | 
            ||
| 225 | * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter  | 
            ||
| 226 | */  | 
            ||
| 227 | View Code Duplication | public function findPks($keys, ConnectionInterface $con = null)  | 
            |
| 240 | |||
| 241 | /**  | 
            ||
| 242 | * Filter the query by primary key  | 
            ||
| 243 | *  | 
            ||
| 244 | * @param mixed $key Primary key to use for the query  | 
            ||
| 245 | *  | 
            ||
| 246 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 247 | */  | 
            ||
| 248 | public function filterByPrimaryKey($key)  | 
            ||
| 255 | |||
| 256 | /**  | 
            ||
| 257 | * Filter the query by a list of primary keys  | 
            ||
| 258 | *  | 
            ||
| 259 | * @param array $keys The list of primary key to use for the query  | 
            ||
| 260 | *  | 
            ||
| 261 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 262 | */  | 
            ||
| 263 | View Code Duplication | public function filterByPrimaryKeys($keys)  | 
            |
| 277 | |||
| 278 | /**  | 
            ||
| 279 | * Filter the query on the id column  | 
            ||
| 280 | *  | 
            ||
| 281 | * Example usage:  | 
            ||
| 282 | * <code>  | 
            ||
| 283 | * $query->filterById(1234); // WHERE id = 1234  | 
            ||
| 284 | * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)  | 
            ||
| 285 |      * $query->filterById(array('min' => 12)); // WHERE id > 12 | 
            ||
| 286 | * </code>  | 
            ||
| 287 | *  | 
            ||
| 288 | * @see filterByBannerImage()  | 
            ||
| 289 | *  | 
            ||
| 290 | * @param mixed $id The value to use as filter.  | 
            ||
| 291 | * Use scalar values for equality.  | 
            ||
| 292 | * Use array values for in_array() equivalent.  | 
            ||
| 293 |      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. | 
            ||
| 294 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 295 | *  | 
            ||
| 296 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 297 | */  | 
            ||
| 298 | View Code Duplication | public function filterById($id = null, $comparison = null)  | 
            |
| 320 | |||
| 321 | /**  | 
            ||
| 322 | * Filter the query on the locale column  | 
            ||
| 323 | *  | 
            ||
| 324 | * Example usage:  | 
            ||
| 325 | * <code>  | 
            ||
| 326 |      * $query->filterByLocale('fooValue');   // WHERE locale = 'fooValue' | 
            ||
| 327 |      * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' | 
            ||
| 328 | * </code>  | 
            ||
| 329 | *  | 
            ||
| 330 | * @param string $locale The value to use as filter.  | 
            ||
| 331 | * Accepts wildcards (* and % trigger a LIKE)  | 
            ||
| 332 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 333 | *  | 
            ||
| 334 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 335 | */  | 
            ||
| 336 | View Code Duplication | public function filterByLocale($locale = null, $comparison = null)  | 
            |
| 349 | |||
| 350 | /**  | 
            ||
| 351 | * Filter the query on the src column  | 
            ||
| 352 | *  | 
            ||
| 353 | * Example usage:  | 
            ||
| 354 | * <code>  | 
            ||
| 355 |      * $query->filterBySrc('fooValue');   // WHERE src = 'fooValue' | 
            ||
| 356 |      * $query->filterBySrc('%fooValue%'); // WHERE src LIKE '%fooValue%' | 
            ||
| 357 | * </code>  | 
            ||
| 358 | *  | 
            ||
| 359 | * @param string $src The value to use as filter.  | 
            ||
| 360 | * Accepts wildcards (* and % trigger a LIKE)  | 
            ||
| 361 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 362 | *  | 
            ||
| 363 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 364 | */  | 
            ||
| 365 | View Code Duplication | public function filterBySrc($src = null, $comparison = null)  | 
            |
| 378 | |||
| 379 | /**  | 
            ||
| 380 | * Filter the query on the name column  | 
            ||
| 381 | *  | 
            ||
| 382 | * Example usage:  | 
            ||
| 383 | * <code>  | 
            ||
| 384 |      * $query->filterByName('fooValue');   // WHERE name = 'fooValue' | 
            ||
| 385 |      * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' | 
            ||
| 386 | * </code>  | 
            ||
| 387 | *  | 
            ||
| 388 | * @param string $name The value to use as filter.  | 
            ||
| 389 | * Accepts wildcards (* and % trigger a LIKE)  | 
            ||
| 390 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 391 | *  | 
            ||
| 392 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 393 | */  | 
            ||
| 394 | View Code Duplication | public function filterByName($name = null, $comparison = null)  | 
            |
| 407 | |||
| 408 | /**  | 
            ||
| 409 | * Filter the query on the clicks column  | 
            ||
| 410 | *  | 
            ||
| 411 | * Example usage:  | 
            ||
| 412 | * <code>  | 
            ||
| 413 | * $query->filterByClicks(1234); // WHERE clicks = 1234  | 
            ||
| 414 | * $query->filterByClicks(array(12, 34)); // WHERE clicks IN (12, 34)  | 
            ||
| 415 |      * $query->filterByClicks(array('min' => 12)); // WHERE clicks > 12 | 
            ||
| 416 | * </code>  | 
            ||
| 417 | *  | 
            ||
| 418 | * @param mixed $clicks The value to use as filter.  | 
            ||
| 419 | * Use scalar values for equality.  | 
            ||
| 420 | * Use array values for in_array() equivalent.  | 
            ||
| 421 |      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. | 
            ||
| 422 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 423 | *  | 
            ||
| 424 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 425 | */  | 
            ||
| 426 | View Code Duplication | public function filterByClicks($clicks = null, $comparison = null)  | 
            |
| 448 | |||
| 449 | /**  | 
            ||
| 450 | * Filter the query on the description column  | 
            ||
| 451 | *  | 
            ||
| 452 | * Example usage:  | 
            ||
| 453 | * <code>  | 
            ||
| 454 |      * $query->filterByDescription('fooValue');   // WHERE description = 'fooValue' | 
            ||
| 455 |      * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' | 
            ||
| 456 | * </code>  | 
            ||
| 457 | *  | 
            ||
| 458 | * @param string $description The value to use as filter.  | 
            ||
| 459 | * Accepts wildcards (* and % trigger a LIKE)  | 
            ||
| 460 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 461 | *  | 
            ||
| 462 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 463 | */  | 
            ||
| 464 | View Code Duplication | public function filterByDescription($description = null, $comparison = null)  | 
            |
| 477 | |||
| 478 | /**  | 
            ||
| 479 | * Filter the query by a related \xbanners\models\BannerImage object  | 
            ||
| 480 | *  | 
            ||
| 481 | * @param \xbanners\models\BannerImage|ObjectCollection $bannerImage The related object(s) to use as filter  | 
            ||
| 482 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 483 | *  | 
            ||
| 484 | * @throws \Propel\Runtime\Exception\PropelException  | 
            ||
| 485 | *  | 
            ||
| 486 | * @return ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 487 | */  | 
            ||
| 488 | View Code Duplication | public function filterByBannerImage($bannerImage, $comparison = null)  | 
            |
| 504 | |||
| 505 | /**  | 
            ||
| 506 | * Adds a JOIN clause to the query using the BannerImage relation  | 
            ||
| 507 | *  | 
            ||
| 508 | * @param string $relationAlias optional alias for the relation  | 
            ||
| 509 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'  | 
            ||
| 510 | *  | 
            ||
| 511 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 512 | */  | 
            ||
| 513 | View Code Duplication | public function joinBannerImage($relationAlias = null, $joinType = 'LEFT JOIN')  | 
            |
| 536 | |||
| 537 | /**  | 
            ||
| 538 | * Use the BannerImage relation BannerImage object  | 
            ||
| 539 | *  | 
            ||
| 540 | * @see useQuery()  | 
            ||
| 541 | *  | 
            ||
| 542 | * @param string $relationAlias optional alias for the relation,  | 
            ||
| 543 | * to be used as main alias in the secondary query  | 
            ||
| 544 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'  | 
            ||
| 545 | *  | 
            ||
| 546 | * @return \xbanners\models\BannerImageQuery A secondary query class using the current class as primary query  | 
            ||
| 547 | */  | 
            ||
| 548 | public function useBannerImageQuery($relationAlias = null, $joinType = 'LEFT JOIN')  | 
            ||
| 554 | |||
| 555 | /**  | 
            ||
| 556 | * Exclude object from result  | 
            ||
| 557 | *  | 
            ||
| 558 | * @param ChildBannerImageI18n $bannerImageI18n Object to remove from the list of results  | 
            ||
| 559 | *  | 
            ||
| 560 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface  | 
            ||
| 561 | */  | 
            ||
| 562 | View Code Duplication | public function prune($bannerImageI18n = null)  | 
            |
| 572 | |||
| 573 | /**  | 
            ||
| 574 | * Deletes all rows from the banner_image_i18n table.  | 
            ||
| 575 | *  | 
            ||
| 576 | * @param ConnectionInterface $con the connection to use  | 
            ||
| 577 | * @return int The number of affected rows (if supported by underlying database driver).  | 
            ||
| 578 | */  | 
            ||
| 579 | public function doDeleteAll(ConnectionInterface $con = null)  | 
            ||
| 599 | |||
| 600 | /**  | 
            ||
| 601 | * Performs a DELETE on the database based on the current ModelCriteria  | 
            ||
| 602 | *  | 
            ||
| 603 | * @param ConnectionInterface $con the connection to use  | 
            ||
| 604 | * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows  | 
            ||
| 605 | * if supported by native driver or if emulated using Propel.  | 
            ||
| 606 | * @throws PropelException Any exceptions caught during processing will be  | 
            ||
| 607 | * rethrown wrapped into a PropelException.  | 
            ||
| 608 | */  | 
            ||
| 609 | View Code Duplication | public function delete(ConnectionInterface $con = null)  | 
            |
| 633 | |||
| 634 | } // BannerImageI18nQuery  | 
            ||
| 635 |