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) |
|
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%', Criteria::LIKE); // WHERE locale LIKE '%fooValue%' |
||
334 | * </code> |
||
335 | * |
||
336 | * @param string $locale The value to use as filter. |
||
337 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
338 | * |
||
339 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
340 | */ |
||
341 | View Code Duplication | public function filterByLocale($locale = null, $comparison = null) |
|
351 | |||
352 | /** |
||
353 | * Filter the query on the src column |
||
354 | * |
||
355 | * Example usage: |
||
356 | * <code> |
||
357 | * $query->filterBySrc('fooValue'); // WHERE src = 'fooValue' |
||
358 | * $query->filterBySrc('%fooValue%', Criteria::LIKE); // WHERE src LIKE '%fooValue%' |
||
359 | * </code> |
||
360 | * |
||
361 | * @param string $src The value to use as filter. |
||
362 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
363 | * |
||
364 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
365 | */ |
||
366 | View Code Duplication | public function filterBySrc($src = null, $comparison = null) |
|
376 | |||
377 | /** |
||
378 | * Filter the query on the name column |
||
379 | * |
||
380 | * Example usage: |
||
381 | * <code> |
||
382 | * $query->filterByName('fooValue'); // WHERE name = 'fooValue' |
||
383 | * $query->filterByName('%fooValue%', Criteria::LIKE); // WHERE name LIKE '%fooValue%' |
||
384 | * </code> |
||
385 | * |
||
386 | * @param string $name The value to use as filter. |
||
387 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
388 | * |
||
389 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
390 | */ |
||
391 | View Code Duplication | public function filterByName($name = null, $comparison = null) |
|
401 | |||
402 | /** |
||
403 | * Filter the query on the clicks column |
||
404 | * |
||
405 | * Example usage: |
||
406 | * <code> |
||
407 | * $query->filterByClicks(1234); // WHERE clicks = 1234 |
||
408 | * $query->filterByClicks(array(12, 34)); // WHERE clicks IN (12, 34) |
||
409 | * $query->filterByClicks(array('min' => 12)); // WHERE clicks > 12 |
||
410 | * </code> |
||
411 | * |
||
412 | * @param mixed $clicks The value to use as filter. |
||
413 | * Use scalar values for equality. |
||
414 | * Use array values for in_array() equivalent. |
||
415 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
416 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
417 | * |
||
418 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
419 | */ |
||
420 | View Code Duplication | public function filterByClicks($clicks = null, $comparison = null) |
|
442 | |||
443 | /** |
||
444 | * Filter the query on the description column |
||
445 | * |
||
446 | * Example usage: |
||
447 | * <code> |
||
448 | * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' |
||
449 | * $query->filterByDescription('%fooValue%', Criteria::LIKE); // WHERE description LIKE '%fooValue%' |
||
450 | * </code> |
||
451 | * |
||
452 | * @param string $description The value to use as filter. |
||
453 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
454 | * |
||
455 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
456 | */ |
||
457 | View Code Duplication | public function filterByDescription($description = null, $comparison = null) |
|
467 | |||
468 | /** |
||
469 | * Filter the query by a related \xbanners\models\BannerImage object |
||
470 | * |
||
471 | * @param \xbanners\models\BannerImage|ObjectCollection $bannerImage The related object(s) to use as filter |
||
472 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
473 | * |
||
474 | * @throws \Propel\Runtime\Exception\PropelException |
||
475 | * |
||
476 | * @return ChildBannerImageI18nQuery The current query, for fluid interface |
||
477 | */ |
||
478 | View Code Duplication | public function filterByBannerImage($bannerImage, $comparison = null) |
|
494 | |||
495 | /** |
||
496 | * Adds a JOIN clause to the query using the BannerImage relation |
||
497 | * |
||
498 | * @param string $relationAlias optional alias for the relation |
||
499 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
||
500 | * |
||
501 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
502 | */ |
||
503 | View Code Duplication | public function joinBannerImage($relationAlias = null, $joinType = 'LEFT JOIN') |
|
526 | |||
527 | /** |
||
528 | * Use the BannerImage relation BannerImage object |
||
529 | * |
||
530 | * @see useQuery() |
||
531 | * |
||
532 | * @param string $relationAlias optional alias for the relation, |
||
533 | * to be used as main alias in the secondary query |
||
534 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
||
535 | * |
||
536 | * @return \xbanners\models\BannerImageQuery A secondary query class using the current class as primary query |
||
537 | */ |
||
538 | public function useBannerImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') |
||
544 | |||
545 | /** |
||
546 | * Exclude object from result |
||
547 | * |
||
548 | * @param ChildBannerImageI18n $bannerImageI18n Object to remove from the list of results |
||
549 | * |
||
550 | * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface |
||
551 | */ |
||
552 | View Code Duplication | public function prune($bannerImageI18n = null) |
|
562 | |||
563 | /** |
||
564 | * Deletes all rows from the banner_image_i18n table. |
||
565 | * |
||
566 | * @param ConnectionInterface $con the connection to use |
||
567 | * @return int The number of affected rows (if supported by underlying database driver). |
||
568 | */ |
||
569 | View Code Duplication | public function doDeleteAll(ConnectionInterface $con = null) |
|
589 | |||
590 | /** |
||
591 | * Performs a DELETE on the database based on the current ModelCriteria |
||
592 | * |
||
593 | * @param ConnectionInterface $con the connection to use |
||
594 | * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
||
595 | * if supported by native driver or if emulated using Propel. |
||
596 | * @throws PropelException Any exceptions caught during processing will be |
||
597 | * rethrown wrapped into a PropelException. |
||
598 | */ |
||
599 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
623 | |||
624 | } // BannerImageI18nQuery |
||
625 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.