Completed
Push — development ( 006c45...63d178 )
by Andrij
19:41 queued 09:38
created

BannersI18nQuery   F

Complexity

Total Complexity 73

Size/Duplication

Total Lines 455
Duplicated Lines 13.85 %

Coupling/Cohesion

Components 4
Dependencies 14

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 63
loc 455
rs 2.459
wmc 73
lcom 4
cbo 14

17 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 15 15 4
D findPk() 0 27 20
A filterByPrimaryKey() 0 7 1
B filterById() 22 22 6
A useBannersQuery() 0 6 2
A doDeleteAll() 0 20 2
C findPkSimple() 0 23 9
A findPkComplex() 0 10 2
A findPks() 0 13 3
A filterByPrimaryKeys() 0 14 3
A filterByLocale() 13 13 4
A filterByName() 13 13 4
A filterByBanners() 0 16 4
B joinBanners() 0 23 4
A prune() 0 10 2
B delete() 0 24 2

How to fix   Duplicated Code    Complexity   

Duplicated Code

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 Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

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
2
3
namespace xbanners\models\Base;
4
5
use \Exception;
6
use \PDO;
7
use Propel\Runtime\Propel;
8
use Propel\Runtime\ActiveQuery\Criteria;
9
use Propel\Runtime\ActiveQuery\ModelCriteria;
10
use Propel\Runtime\ActiveQuery\ModelJoin;
11
use Propel\Runtime\Collection\ObjectCollection;
12
use Propel\Runtime\Connection\ConnectionInterface;
13
use Propel\Runtime\Exception\PropelException;
14
use xbanners\models\BannersI18n as ChildBannersI18n;
15
use xbanners\models\BannersI18nQuery as ChildBannersI18nQuery;
16
use xbanners\models\Map\BannersI18nTableMap;
17
18
/**
19
 * Base class that represents a query for the 'banners_i18n' table.
20
 *
21
 *
22
 *
23
 * @method     ChildBannersI18nQuery orderById($order = Criteria::ASC) Order by the id column
24
 * @method     ChildBannersI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
25
 * @method     ChildBannersI18nQuery orderByName($order = Criteria::ASC) Order by the name column
26
 *
27
 * @method     ChildBannersI18nQuery groupById() Group by the id column
28
 * @method     ChildBannersI18nQuery groupByLocale() Group by the locale column
29
 * @method     ChildBannersI18nQuery groupByName() Group by the name column
30
 *
31
 * @method     ChildBannersI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
32
 * @method     ChildBannersI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
33
 * @method     ChildBannersI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
34
 *
35
 * @method     ChildBannersI18nQuery leftJoinWith($relation) Adds a LEFT JOIN clause and with to the query
36
 * @method     ChildBannersI18nQuery rightJoinWith($relation) Adds a RIGHT JOIN clause and with to the query
37
 * @method     ChildBannersI18nQuery innerJoinWith($relation) Adds a INNER JOIN clause and with to the query
38
 *
39
 * @method     ChildBannersI18nQuery leftJoinBanners($relationAlias = null) Adds a LEFT JOIN clause to the query using the Banners relation
40
 * @method     ChildBannersI18nQuery rightJoinBanners($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Banners relation
41
 * @method     ChildBannersI18nQuery innerJoinBanners($relationAlias = null) Adds a INNER JOIN clause to the query using the Banners relation
42
 *
43
 * @method     ChildBannersI18nQuery joinWithBanners($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the Banners relation
44
 *
45
 * @method     ChildBannersI18nQuery leftJoinWithBanners() Adds a LEFT JOIN clause and with to the query using the Banners relation
46
 * @method     ChildBannersI18nQuery rightJoinWithBanners() Adds a RIGHT JOIN clause and with to the query using the Banners relation
47
 * @method     ChildBannersI18nQuery innerJoinWithBanners() Adds a INNER JOIN clause and with to the query using the Banners relation
48
 *
49
 * @method     \xbanners\models\BannersQuery endUse() Finalizes a secondary criteria and merges it with its primary Criteria
50
 *
51
 * @method     ChildBannersI18n findOne(ConnectionInterface $con = null) Return the first ChildBannersI18n matching the query
52
 * @method     ChildBannersI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildBannersI18n matching the query, or a new ChildBannersI18n object populated from the query conditions when no match is found
53
 *
54
 * @method     ChildBannersI18n findOneById(int $id) Return the first ChildBannersI18n filtered by the id column
55
 * @method     ChildBannersI18n findOneByLocale(string $locale) Return the first ChildBannersI18n filtered by the locale column
56
 * @method     ChildBannersI18n findOneByName(string $name) Return the first ChildBannersI18n filtered by the name column *
57
58
 * @method     ChildBannersI18n requirePk($key, ConnectionInterface $con = null) Return the ChildBannersI18n by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
59
 * @method     ChildBannersI18n requireOne(ConnectionInterface $con = null) Return the first ChildBannersI18n matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
60
 *
61
 * @method     ChildBannersI18n requireOneById(int $id) Return the first ChildBannersI18n filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
62
 * @method     ChildBannersI18n requireOneByLocale(string $locale) Return the first ChildBannersI18n filtered by the locale column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
63
 * @method     ChildBannersI18n requireOneByName(string $name) Return the first ChildBannersI18n filtered by the name column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
64
 *
65
 * @method     ChildBannersI18n[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildBannersI18n objects based on current ModelCriteria
66
 * @method     ChildBannersI18n[]|ObjectCollection findById(int $id) Return ChildBannersI18n objects filtered by the id column
67
 * @method     ChildBannersI18n[]|ObjectCollection findByLocale(string $locale) Return ChildBannersI18n objects filtered by the locale column
68
 * @method     ChildBannersI18n[]|ObjectCollection findByName(string $name) Return ChildBannersI18n objects filtered by the name column
69
 * @method     ChildBannersI18n[]|\Propel\Runtime\Util\PropelModelPager paginate($page = 1, $maxPerPage = 10, ConnectionInterface $con = null) Issue a SELECT query based on the current ModelCriteria and uses a page and a maximum number of results per page to compute an offset and a limit
70
 *
71
 */
0 ignored issues
show
introduced by
Additional blank lines found at end of doc comment
Loading history...
72
abstract class BannersI18nQuery extends ModelCriteria
73
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
74
    protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException';
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
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)
84
    {
85
        parent::__construct($dbName, $modelName, $modelAlias);
86
    }
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)
97
    {
98
        if ($criteria instanceof ChildBannersI18nQuery) {
99
            return $criteria;
100
        }
101
        $query = new ChildBannersI18nQuery();
102
        if (null !== $modelAlias) {
103
            $query->setModelAlias($modelAlias);
104
        }
105
        if ($criteria instanceof Criteria) {
106
            $query->mergeWith($criteria);
107
        }
108
109
        return $query;
110
    }
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>
0 ignored issues
show
introduced by
Doc comment long description must start with a capital letter
Loading history...
118
     * $obj = $c->findPk(array(12, 34), $con);
119
     * </code>
120
     *
121
     * @param array[$id, $locale] $key Primary key to use for the query
0 ignored issues
show
Documentation introduced by
The doc-type array[$id, could not be parsed: Expected "]" at position 2, but found "$id". (view supported doc-types)

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.

Loading history...
Bug introduced by
There is no parameter named $locale]. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
introduced by
Expected 1 spaces after parameter type; 0 found
Loading history...
introduced by
Doc comment for parameter $id, does not match actual variable name $con
Loading history...
122
     * @param ConnectionInterface $con an optional connection object
123
     *
124
     * @return ChildBannersI18n|array|mixed the result, formatted by the current formatter
125
     */
126
    public function findPk($key, ConnectionInterface $con = null)
127
    {
128
        if ($key === null) {
129
            return null;
130
        }
131
132
        if ($con === null) {
133
            $con = Propel::getServiceContainer()->getReadConnection(BannersI18nTableMap::DATABASE_NAME);
134
        }
135
136
        $this->basePreSelect($con);
137
138
        if (
0 ignored issues
show
Coding Style introduced by
First condition of a multi-line IF statement must directly follow the opening parenthesis
Loading history...
139
            $this->formatter || $this->modelAlias || $this->with || $this->select
0 ignored issues
show
Coding Style introduced by
Each line in a multi-line IF statement must begin with a boolean operator
Loading history...
140
            || $this->selectColumns || $this->asColumns || $this->selectModifiers
141
            || $this->map || $this->having || $this->joins
142
        ) {
143
            return $this->findPkComplex($key, $con);
144
        }
145
146
        if ((null !== ($obj = BannersI18nTableMap::getInstanceFromPool(serialize([(null === $key[0] || is_scalar($key[0]) || is_callable([$key[0], '__toString']) ? (string) $key[0] : $key[0]), (null === $key[1] || is_scalar($key[1]) || is_callable([$key[1], '__toString']) ? (string) $key[1] : $key[1])]))))) {
147
            // the object is already in the instance pool
148
            return $obj;
149
        }
150
151
        return $this->findPkSimple($key, $con);
152
    }
153
154
    /**
155
     * Find object by primary key using raw SQL to go fast.
156
     * Bypass doSelect() and the object formatter by using generated code.
157
     *
158
     * @param     mixed $key Primary key to use for the query
159
     * @param     ConnectionInterface $con A connection object
160
     *
161
     * @throws \Propel\Runtime\Exception\PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
162
     *
163
     * @return ChildBannersI18n A model object, or null if the key is not found
0 ignored issues
show
Documentation introduced by
Should the return type not be ChildBannersI18n|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
164
     */
165
    protected function findPkSimple($key, ConnectionInterface $con)
166
    {
167
        $sql = 'SELECT id, locale, name FROM banners_i18n WHERE id = :p0 AND locale = :p1';
168
        try {
169
            $stmt = $con->prepare($sql);
170
            $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
171
            $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
172
            $stmt->execute();
173
        } catch (Exception $e) {
174
            Propel::log($e->getMessage(), Propel::LOG_ERR);
175
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
176
        }
177
        $obj = null;
178
        if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
179
            /** @var ChildBannersI18n $obj */
180
            $obj = new ChildBannersI18n();
181
            $obj->hydrate($row);
182
            BannersI18nTableMap::addInstanceToPool($obj, serialize([(null === $key[0] || is_scalar($key[0]) || is_callable([$key[0], '__toString']) ? (string) $key[0] : $key[0]), (null === $key[1] || is_scalar($key[1]) || is_callable([$key[1], '__toString']) ? (string) $key[1] : $key[1])]));
183
        }
184
        $stmt->closeCursor();
185
186
        return $obj;
187
    }
188
189
    /**
190
     * Find object by primary key.
191
     *
192
     * @param     mixed $key Primary key to use for the query
193
     * @param     ConnectionInterface $con A connection object
194
     *
195
     * @return ChildBannersI18n|array|mixed the result, formatted by the current formatter
196
     */
197
    protected function findPkComplex($key, ConnectionInterface $con)
198
    {
199
        // As the query uses a PK condition, no limit(1) is necessary.
200
        $criteria = $this->isKeepQuery() ? clone $this : $this;
201
        $dataFetcher = $criteria
202
            ->filterByPrimaryKey($key)
203
            ->doSelect($con);
204
205
        return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
206
    }
207
208
    /**
209
     * Find objects by primary key
210
     * <code>
211
     * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
212
     * </code>
213
     * @param     array $keys Primary keys to use for the query
214
     * @param     ConnectionInterface $con an optional connection object
215
     *
216
     * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
217
     */
218
    public function findPks($keys, ConnectionInterface $con = null)
219
    {
220
        if (null === $con) {
221
            $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
222
        }
223
        $this->basePreSelect($con);
224
        $criteria = $this->isKeepQuery() ? clone $this : $this;
225
        $dataFetcher = $criteria
226
            ->filterByPrimaryKeys($keys)
227
            ->doSelect($con);
228
229
        return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
230
    }
231
232
    /**
233
     * Filter the query by primary key
234
     *
235
     * @param     mixed $key Primary key to use for the query
236
     *
237
     * @return $this|ChildBannersI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
238
     */
239
    public function filterByPrimaryKey($key)
240
    {
241
        $this->addUsingAlias(BannersI18nTableMap::COL_ID, $key[0], Criteria::EQUAL);
242
        $this->addUsingAlias(BannersI18nTableMap::COL_LOCALE, $key[1], Criteria::EQUAL);
243
244
        return $this;
245
    }
246
247
    /**
248
     * Filter the query by a list of primary keys
249
     *
250
     * @param     array $keys The list of primary key to use for the query
251
     *
252
     * @return $this|ChildBannersI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
253
     */
254
    public function filterByPrimaryKeys($keys)
255
    {
256
        if (empty($keys)) {
257
            return $this->add(null, '1<>1', Criteria::CUSTOM);
258
        }
259
        foreach ($keys as $key) {
260
            $cton0 = $this->getNewCriterion(BannersI18nTableMap::COL_ID, $key[0], Criteria::EQUAL);
261
            $cton1 = $this->getNewCriterion(BannersI18nTableMap::COL_LOCALE, $key[1], Criteria::EQUAL);
262
            $cton0->addAnd($cton1);
263
            $this->addOr($cton0);
264
        }
265
266
        return $this;
267
    }
268
269
    /**
270
     * Filter the query on the id column
271
     *
272
     * Example usage:
273
     * <code>
274
     * $query->filterById(1234); // WHERE id = 1234
275
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
276
     * $query->filterById(array('min' => 12)); // WHERE id > 12
277
     * </code>
278
     *
279
     * @see       filterByBanners()
280
     *
281
     * @param     mixed $id The value to use as filter.
0 ignored issues
show
introduced by
Paramater tags must be defined first in a doc commment
Loading history...
282
     *              Use scalar values for equality.
283
     *              Use array values for in_array() equivalent.
284
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
285
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
286
     *
287
     * @return $this|ChildBannersI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
288
     */
289 View Code Duplication
    public function filterById($id = null, $comparison = null)
290
    {
291
        if (is_array($id)) {
292
            $useMinMax = false;
293
            if (isset($id['min'])) {
294
                $this->addUsingAlias(BannersI18nTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL);
295
                $useMinMax = true;
296
            }
297
            if (isset($id['max'])) {
298
                $this->addUsingAlias(BannersI18nTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL);
299
                $useMinMax = true;
300
            }
301
            if ($useMinMax) {
302
                return $this;
303
            }
304
            if (null === $comparison) {
305
                $comparison = Criteria::IN;
306
            }
307
        }
308
309
        return $this->addUsingAlias(BannersI18nTableMap::COL_ID, $id, $comparison);
310
    }
311
312
    /**
313
     * Filter the query on the locale column
314
     *
315
     * Example usage:
316
     * <code>
317
     * $query->filterByLocale('fooValue');   // WHERE locale = 'fooValue'
318
     * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
319
     * </code>
320
     *
321
     * @param     string $locale The value to use as filter.
322
     *              Accepts wildcards (* and % trigger a LIKE)
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
323
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
324
     *
325
     * @return $this|ChildBannersI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
326
     */
327 View Code Duplication
    public function filterByLocale($locale = null, $comparison = null)
328
    {
329
        if (null === $comparison) {
330
            if (is_array($locale)) {
331
                $comparison = Criteria::IN;
332
            } elseif (preg_match('/[\%\*]/', $locale)) {
333
                $locale = str_replace('*', '%', $locale);
334
                $comparison = Criteria::LIKE;
335
            }
336
        }
337
338
        return $this->addUsingAlias(BannersI18nTableMap::COL_LOCALE, $locale, $comparison);
339
    }
340
341
    /**
342
     * Filter the query on the name column
343
     *
344
     * Example usage:
345
     * <code>
346
     * $query->filterByName('fooValue');   // WHERE name = 'fooValue'
347
     * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
348
     * </code>
349
     *
350
     * @param     string $name The value to use as filter.
351
     *              Accepts wildcards (* and % trigger a LIKE)
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
352
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
353
     *
354
     * @return $this|ChildBannersI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
355
     */
356 View Code Duplication
    public function filterByName($name = null, $comparison = null)
357
    {
358
        if (null === $comparison) {
359
            if (is_array($name)) {
360
                $comparison = Criteria::IN;
361
            } elseif (preg_match('/[\%\*]/', $name)) {
362
                $name = str_replace('*', '%', $name);
363
                $comparison = Criteria::LIKE;
364
            }
365
        }
366
367
        return $this->addUsingAlias(BannersI18nTableMap::COL_NAME, $name, $comparison);
368
    }
369
370
    /**
371
     * Filter the query by a related \xbanners\models\Banners object
372
     *
373
     * @param \xbanners\models\Banners|ObjectCollection $banners The related object(s) to use as filter
374
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
375
     *
376
     * @throws \Propel\Runtime\Exception\PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
377
     *
378
     * @return ChildBannersI18nQuery The current query, for fluid interface
379
     */
380
    public function filterByBanners($banners, $comparison = null)
381
    {
382
        if ($banners instanceof \xbanners\models\Banners) {
383
            return $this
384
                ->addUsingAlias(BannersI18nTableMap::COL_ID, $banners->getId(), $comparison);
385
        } elseif ($banners instanceof ObjectCollection) {
386
            if (null === $comparison) {
387
                $comparison = Criteria::IN;
388
            }
389
390
            return $this
391
                ->addUsingAlias(BannersI18nTableMap::COL_ID, $banners->toKeyValue('PrimaryKey', 'Id'), $comparison);
392
        } else {
393
            throw new PropelException('filterByBanners() only accepts arguments of type \xbanners\models\Banners or Collection');
394
        }
395
    }
396
397
    /**
398
     * Adds a JOIN clause to the query using the Banners relation
399
     *
400
     * @param     string $relationAlias optional alias for the relation
401
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
402
     *
403
     * @return $this|ChildBannersI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
404
     */
405
    public function joinBanners($relationAlias = null, $joinType = 'LEFT JOIN')
406
    {
407
        $tableMap = $this->getTableMap();
408
        $relationMap = $tableMap->getRelation('Banners');
409
410
        // create a ModelJoin object for this join
411
        $join = new ModelJoin();
412
        $join->setJoinType($joinType);
413
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
414
        if ($previousJoin = $this->getPreviousJoin()) {
415
            $join->setPreviousJoin($previousJoin);
0 ignored issues
show
Compatibility introduced by
$previousJoin of type object<Propel\Runtime\ActiveQuery\Join> is not a sub-type of object<Propel\Runtime\ActiveQuery\ModelJoin>. It seems like you assume a child class of the class Propel\Runtime\ActiveQuery\Join to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
416
        }
417
418
        // add the ModelJoin to the current object
419
        if ($relationAlias) {
420
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
421
            $this->addJoinObject($join, $relationAlias);
422
        } else {
423
            $this->addJoinObject($join, 'Banners');
424
        }
425
426
        return $this;
427
    }
428
429
    /**
430
     * Use the Banners relation Banners object
431
     *
432
     * @see useQuery()
433
     *
434
     * @param     string $relationAlias optional alias for the relation,
0 ignored issues
show
introduced by
Paramater tags must be defined first in a doc commment
Loading history...
435
     *                                   to be used as main alias in the secondary query
0 ignored issues
show
introduced by
Parameter comment must start with a capital letter
Loading history...
introduced by
Parameter comment must end with a full stop
Loading history...
436
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
437
     *
438
     * @return \xbanners\models\BannersQuery A secondary query class using the current class as primary query
439
     */
440
    public function useBannersQuery($relationAlias = null, $joinType = 'LEFT JOIN')
441
    {
442
        return $this
443
            ->joinBanners($relationAlias, $joinType)
444
            ->useQuery($relationAlias ? $relationAlias : 'Banners', '\xbanners\models\BannersQuery');
445
    }
446
447
    /**
448
     * Exclude object from result
449
     *
450
     * @param   ChildBannersI18n $bannersI18n Object to remove from the list of results
451
     *
452
     * @return $this|ChildBannersI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
453
     */
454
    public function prune($bannersI18n = null)
455
    {
456
        if ($bannersI18n) {
457
            $this->addCond('pruneCond0', $this->getAliasedColName(BannersI18nTableMap::COL_ID), $bannersI18n->getId(), Criteria::NOT_EQUAL);
458
            $this->addCond('pruneCond1', $this->getAliasedColName(BannersI18nTableMap::COL_LOCALE), $bannersI18n->getLocale(), Criteria::NOT_EQUAL);
459
            $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
460
        }
461
462
        return $this;
463
    }
464
465
    /**
466
     * Deletes all rows from the banners_i18n table.
467
     *
468
     * @param ConnectionInterface $con the connection to use
469
     * @return int The number of affected rows (if supported by underlying database driver).
470
     */
471
    public function doDeleteAll(ConnectionInterface $con = null)
472
    {
473
        if (null === $con) {
474
            $con = Propel::getServiceContainer()->getWriteConnection(BannersI18nTableMap::DATABASE_NAME);
475
        }
476
477
        // use transaction because $criteria could contain info
478
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
479
        return $con->transaction(function () use ($con) {
480
            $affectedRows = 0; // initialize var to track total num of affected rows
481
            $affectedRows += parent::doDeleteAll($con);
482
            // Because this db requires some delete cascade/set null emulation, we have to
483
            // clear the cached instance *after* the emulation has happened (since
484
            // instances get re-added by the select statement contained therein).
485
            BannersI18nTableMap::clearInstancePool();
486
            BannersI18nTableMap::clearRelatedInstancePool();
487
488
            return $affectedRows;
489
        });
490
    }
491
492
    /**
493
     * Performs a DELETE on the database based on the current ModelCriteria
494
     *
495
     * @param ConnectionInterface $con the connection to use
496
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
497
     *                         if supported by native driver or if emulated using Propel.
498
     * @throws PropelException Any exceptions caught during processing will be
499
     *                         rethrown wrapped into a PropelException.
0 ignored issues
show
introduced by
@throws tag comment must start with a capital letter
Loading history...
500
     */
501
    public function delete(ConnectionInterface $con = null)
502
    {
503
        if (null === $con) {
504
            $con = Propel::getServiceContainer()->getWriteConnection(BannersI18nTableMap::DATABASE_NAME);
505
        }
506
507
        $criteria = $this;
508
509
        // Set the correct dbName
510
        $criteria->setDbName(BannersI18nTableMap::DATABASE_NAME);
511
512
        // use transaction because $criteria could contain info
513
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
514
        return $con->transaction(function () use ($con, $criteria) {
515
            $affectedRows = 0; // initialize var to track total num of affected rows
516
517
            BannersI18nTableMap::removeInstanceFromPool($criteria);
518
519
            $affectedRows += ModelCriteria::delete($con);
520
            BannersI18nTableMap::clearRelatedInstancePool();
521
522
            return $affectedRows;
523
        });
524
    }
525
526
} // BannersI18nQuery
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
527