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 BannersI18nQuery 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 BannersI18nQuery, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 72 | abstract class BannersI18nQuery extends ModelCriteria  | 
            ||
| 73 | { | 
            ||
| 74 | protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException';  | 
            ||
| 75 | |||
| 76 | /**  | 
            ||
| 77 | * Initializes internal state of \xbanners\models\Base\BannersI18nQuery object.  | 
            ||
| 78 | *  | 
            ||
| 79 | * @param string $dbName The database name  | 
            ||
| 80 | * @param string $modelName The phpName of a model, e.g. 'Book'  | 
            ||
| 81 | * @param string $modelAlias The alias for the model in this query, e.g. 'b'  | 
            ||
| 82 | */  | 
            ||
| 83 | public function __construct($dbName = 'Shop', $modelName = '\\xbanners\\models\\BannersI18n', $modelAlias = null)  | 
            ||
| 87 | |||
| 88 | /**  | 
            ||
| 89 | * Returns a new ChildBannersI18nQuery object.  | 
            ||
| 90 | *  | 
            ||
| 91 | * @param string $modelAlias The alias of a model in the query  | 
            ||
| 92 | * @param Criteria $criteria Optional Criteria to build the query from  | 
            ||
| 93 | *  | 
            ||
| 94 | * @return ChildBannersI18nQuery  | 
            ||
| 95 | */  | 
            ||
| 96 | View Code Duplication | public static function create($modelAlias = null, Criteria $criteria = null)  | 
            |
| 111 | |||
| 112 | /**  | 
            ||
| 113 | * Find object by primary key.  | 
            ||
| 114 | * Propel uses the instance pool to skip the database if the object exists.  | 
            ||
| 115 | * Go fast if the query is untouched.  | 
            ||
| 116 | *  | 
            ||
| 117 | * <code>  | 
            ||
| 118 | * $obj = $c->findPk(array(12, 34), $con);  | 
            ||
| 119 | * </code>  | 
            ||
| 120 | *  | 
            ||
| 121 | * @param array[$id, $locale] $key Primary key to use for the query  | 
            ||
| 122 | * @param ConnectionInterface $con an optional connection object  | 
            ||
| 123 | *  | 
            ||
| 124 | * @return ChildBannersI18n|array|mixed the result, formatted by the current formatter  | 
            ||
| 125 | */  | 
            ||
| 126 | View Code Duplication | public function findPk($key, ConnectionInterface $con = null)  | 
            |
| 147 | |||
| 148 | /**  | 
            ||
| 149 | * Find object by primary key using raw SQL to go fast.  | 
            ||
| 150 | * Bypass doSelect() and the object formatter by using generated code.  | 
            ||
| 151 | *  | 
            ||
| 152 | * @param mixed $key Primary key to use for the query  | 
            ||
| 153 | * @param ConnectionInterface $con A connection object  | 
            ||
| 154 | *  | 
            ||
| 155 | * @throws \Propel\Runtime\Exception\PropelException  | 
            ||
| 156 | *  | 
            ||
| 157 | * @return ChildBannersI18n A model object, or null if the key is not found  | 
            ||
| 158 | */  | 
            ||
| 159 | View Code Duplication | protected function findPkSimple($key, ConnectionInterface $con)  | 
            |
| 182 | |||
| 183 | /**  | 
            ||
| 184 | * Find object by primary key.  | 
            ||
| 185 | *  | 
            ||
| 186 | * @param mixed $key Primary key to use for the query  | 
            ||
| 187 | * @param ConnectionInterface $con A connection object  | 
            ||
| 188 | *  | 
            ||
| 189 | * @return ChildBannersI18n|array|mixed the result, formatted by the current formatter  | 
            ||
| 190 | */  | 
            ||
| 191 | View Code Duplication | protected function findPkComplex($key, ConnectionInterface $con)  | 
            |
| 201 | |||
| 202 | /**  | 
            ||
| 203 | * Find objects by primary key  | 
            ||
| 204 | * <code>  | 
            ||
| 205 | * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);  | 
            ||
| 206 | * </code>  | 
            ||
| 207 | * @param array $keys Primary keys to use for the query  | 
            ||
| 208 | * @param ConnectionInterface $con an optional connection object  | 
            ||
| 209 | *  | 
            ||
| 210 | * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter  | 
            ||
| 211 | */  | 
            ||
| 212 | View Code Duplication | public function findPks($keys, ConnectionInterface $con = null)  | 
            |
| 225 | |||
| 226 | /**  | 
            ||
| 227 | * Filter the query by primary key  | 
            ||
| 228 | *  | 
            ||
| 229 | * @param mixed $key Primary key to use for the query  | 
            ||
| 230 | *  | 
            ||
| 231 | * @return $this|ChildBannersI18nQuery The current query, for fluid interface  | 
            ||
| 232 | */  | 
            ||
| 233 | public function filterByPrimaryKey($key)  | 
            ||
| 240 | |||
| 241 | /**  | 
            ||
| 242 | * Filter the query by a list of primary keys  | 
            ||
| 243 | *  | 
            ||
| 244 | * @param array $keys The list of primary key to use for the query  | 
            ||
| 245 | *  | 
            ||
| 246 | * @return $this|ChildBannersI18nQuery The current query, for fluid interface  | 
            ||
| 247 | */  | 
            ||
| 248 | View Code Duplication | public function filterByPrimaryKeys($keys)  | 
            |
| 262 | |||
| 263 | /**  | 
            ||
| 264 | * Filter the query on the id column  | 
            ||
| 265 | *  | 
            ||
| 266 | * Example usage:  | 
            ||
| 267 | * <code>  | 
            ||
| 268 | * $query->filterById(1234); // WHERE id = 1234  | 
            ||
| 269 | * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)  | 
            ||
| 270 |      * $query->filterById(array('min' => 12)); // WHERE id > 12 | 
            ||
| 271 | * </code>  | 
            ||
| 272 | *  | 
            ||
| 273 | * @see filterByBanners()  | 
            ||
| 274 | *  | 
            ||
| 275 | * @param mixed $id The value to use as filter.  | 
            ||
| 276 | * Use scalar values for equality.  | 
            ||
| 277 | * Use array values for in_array() equivalent.  | 
            ||
| 278 |      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. | 
            ||
| 279 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 280 | *  | 
            ||
| 281 | * @return $this|ChildBannersI18nQuery The current query, for fluid interface  | 
            ||
| 282 | */  | 
            ||
| 283 | View Code Duplication | public function filterById($id = null, $comparison = null)  | 
            |
| 305 | |||
| 306 | /**  | 
            ||
| 307 | * Filter the query on the locale column  | 
            ||
| 308 | *  | 
            ||
| 309 | * Example usage:  | 
            ||
| 310 | * <code>  | 
            ||
| 311 |      * $query->filterByLocale('fooValue');   // WHERE locale = 'fooValue' | 
            ||
| 312 |      * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' | 
            ||
| 313 | * </code>  | 
            ||
| 314 | *  | 
            ||
| 315 | * @param string $locale The value to use as filter.  | 
            ||
| 316 | * Accepts wildcards (* and % trigger a LIKE)  | 
            ||
| 317 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 318 | *  | 
            ||
| 319 | * @return $this|ChildBannersI18nQuery The current query, for fluid interface  | 
            ||
| 320 | */  | 
            ||
| 321 | View Code Duplication | public function filterByLocale($locale = null, $comparison = null)  | 
            |
| 334 | |||
| 335 | /**  | 
            ||
| 336 | * Filter the query on the name column  | 
            ||
| 337 | *  | 
            ||
| 338 | * Example usage:  | 
            ||
| 339 | * <code>  | 
            ||
| 340 |      * $query->filterByName('fooValue');   // WHERE name = 'fooValue' | 
            ||
| 341 |      * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' | 
            ||
| 342 | * </code>  | 
            ||
| 343 | *  | 
            ||
| 344 | * @param string $name The value to use as filter.  | 
            ||
| 345 | * Accepts wildcards (* and % trigger a LIKE)  | 
            ||
| 346 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 347 | *  | 
            ||
| 348 | * @return $this|ChildBannersI18nQuery The current query, for fluid interface  | 
            ||
| 349 | */  | 
            ||
| 350 | View Code Duplication | public function filterByName($name = null, $comparison = null)  | 
            |
| 363 | |||
| 364 | /**  | 
            ||
| 365 | * Filter the query by a related \xbanners\models\Banners object  | 
            ||
| 366 | *  | 
            ||
| 367 | * @param \xbanners\models\Banners|ObjectCollection $banners The related object(s) to use as filter  | 
            ||
| 368 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL  | 
            ||
| 369 | *  | 
            ||
| 370 | * @throws \Propel\Runtime\Exception\PropelException  | 
            ||
| 371 | *  | 
            ||
| 372 | * @return ChildBannersI18nQuery The current query, for fluid interface  | 
            ||
| 373 | */  | 
            ||
| 374 | View Code Duplication | public function filterByBanners($banners, $comparison = null)  | 
            |
| 390 | |||
| 391 | /**  | 
            ||
| 392 | * Adds a JOIN clause to the query using the Banners relation  | 
            ||
| 393 | *  | 
            ||
| 394 | * @param string $relationAlias optional alias for the relation  | 
            ||
| 395 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'  | 
            ||
| 396 | *  | 
            ||
| 397 | * @return $this|ChildBannersI18nQuery The current query, for fluid interface  | 
            ||
| 398 | */  | 
            ||
| 399 | View Code Duplication | public function joinBanners($relationAlias = null, $joinType = 'LEFT JOIN')  | 
            |
| 422 | |||
| 423 | /**  | 
            ||
| 424 | * Use the Banners relation Banners object  | 
            ||
| 425 | *  | 
            ||
| 426 | * @see useQuery()  | 
            ||
| 427 | *  | 
            ||
| 428 | * @param string $relationAlias optional alias for the relation,  | 
            ||
| 429 | * to be used as main alias in the secondary query  | 
            ||
| 430 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'  | 
            ||
| 431 | *  | 
            ||
| 432 | * @return \xbanners\models\BannersQuery A secondary query class using the current class as primary query  | 
            ||
| 433 | */  | 
            ||
| 434 | public function useBannersQuery($relationAlias = null, $joinType = 'LEFT JOIN')  | 
            ||
| 440 | |||
| 441 | /**  | 
            ||
| 442 | * Exclude object from result  | 
            ||
| 443 | *  | 
            ||
| 444 | * @param ChildBannersI18n $bannersI18n Object to remove from the list of results  | 
            ||
| 445 | *  | 
            ||
| 446 | * @return $this|ChildBannersI18nQuery The current query, for fluid interface  | 
            ||
| 447 | */  | 
            ||
| 448 | View Code Duplication | public function prune($bannersI18n = null)  | 
            |
| 458 | |||
| 459 | /**  | 
            ||
| 460 | * Deletes all rows from the banners_i18n table.  | 
            ||
| 461 | *  | 
            ||
| 462 | * @param ConnectionInterface $con the connection to use  | 
            ||
| 463 | * @return int The number of affected rows (if supported by underlying database driver).  | 
            ||
| 464 | */  | 
            ||
| 465 | public function doDeleteAll(ConnectionInterface $con = null)  | 
            ||
| 485 | |||
| 486 | /**  | 
            ||
| 487 | * Performs a DELETE on the database based on the current ModelCriteria  | 
            ||
| 488 | *  | 
            ||
| 489 | * @param ConnectionInterface $con the connection to use  | 
            ||
| 490 | * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows  | 
            ||
| 491 | * if supported by native driver or if emulated using Propel.  | 
            ||
| 492 | * @throws PropelException Any exceptions caught during processing will be  | 
            ||
| 493 | * rethrown wrapped into a PropelException.  | 
            ||
| 494 | */  | 
            ||
| 495 | View Code Duplication | public function delete(ConnectionInterface $con = null)  | 
            |
| 519 | |||
| 520 | } // BannersI18nQuery  | 
            ||
| 521 |