Completed
Push — development ( 9ca09c...006c45 )
by Andrij
09:50
created

BannersQuery   D

Complexity

Total Complexity 96

Size/Duplication

Total Lines 719
Duplicated Lines 33.66 %

Coupling/Cohesion

Components 2
Dependencies 7

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 96
c 4
b 0
f 0
lcom 2
cbo 7
dl 242
loc 719
rs 4.4444

27 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 15 15 4
B findPkSimple() 22 22 6
A filterByPrimaryKey() 0 5 1
A filterByPrimaryKeys() 0 5 1
B filterById() 22 22 6
B filterByWidth() 22 22 6
B filterByHeight() 22 22 6
A filterByBannerImage() 14 14 3
A useBannerImageQuery() 0 6 2
A filterByBannersI18n() 14 14 3
A useBannersI18nQuery() 0 6 2
A prune() 0 8 2
B delete() 28 28 2
B doOnDeleteCascade() 0 25 2
A joinI18n() 8 8 2
A joinWithI18n() 9 9 1
A useI18nQuery() 0 6 2
D findPk() 27 27 17
A findPkComplex() 0 10 2
A findPks() 0 13 3
A filterByPlace() 13 13 4
A filterByEffects() 13 13 4
A filterByPageType() 13 13 4
B joinBannerImage() 0 23 4
B joinBannersI18n() 0 23 4
A doDeleteAll() 0 21 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 BannersQuery 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 BannersQuery, 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\Banners as ChildBanners;
15
use xbanners\models\BannersI18nQuery as ChildBannersI18nQuery;
16
use xbanners\models\BannersQuery as ChildBannersQuery;
17
use xbanners\models\Map\BannerImageTableMap;
18
use xbanners\models\Map\BannersI18nTableMap;
19
use xbanners\models\Map\BannersTableMap;
20
21
/**
22
 * Base class that represents a query for the 'banners' table.
23
 *
24
 *
25
 *
26
 * @method     ChildBannersQuery orderById($order = Criteria::ASC) Order by the id column
27
 * @method     ChildBannersQuery orderByPlace($order = Criteria::ASC) Order by the place column
28
 * @method     ChildBannersQuery orderByWidth($order = Criteria::ASC) Order by the width column
29
 * @method     ChildBannersQuery orderByHeight($order = Criteria::ASC) Order by the height column
30
 * @method     ChildBannersQuery orderByEffects($order = Criteria::ASC) Order by the effects column
31
 * @method     ChildBannersQuery orderByPageType($order = Criteria::ASC) Order by the page_type column
32
 *
33
 * @method     ChildBannersQuery groupById() Group by the id column
34
 * @method     ChildBannersQuery groupByPlace() Group by the place column
35
 * @method     ChildBannersQuery groupByWidth() Group by the width column
36
 * @method     ChildBannersQuery groupByHeight() Group by the height column
37
 * @method     ChildBannersQuery groupByEffects() Group by the effects column
38
 * @method     ChildBannersQuery groupByPageType() Group by the page_type column
39
 *
40
 * @method     ChildBannersQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
41
 * @method     ChildBannersQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
42
 * @method     ChildBannersQuery innerJoin($relation) Adds a INNER JOIN clause to the query
43
 *
44
 * @method     ChildBannersQuery leftJoinWith($relation) Adds a LEFT JOIN clause and with to the query
45
 * @method     ChildBannersQuery rightJoinWith($relation) Adds a RIGHT JOIN clause and with to the query
46
 * @method     ChildBannersQuery innerJoinWith($relation) Adds a INNER JOIN clause and with to the query
47
 *
48
 * @method     ChildBannersQuery leftJoinBannerImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the BannerImage relation
49
 * @method     ChildBannersQuery rightJoinBannerImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BannerImage relation
50
 * @method     ChildBannersQuery innerJoinBannerImage($relationAlias = null) Adds a INNER JOIN clause to the query using the BannerImage relation
51
 *
52
 * @method     ChildBannersQuery joinWithBannerImage($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the BannerImage relation
53
 *
54
 * @method     ChildBannersQuery leftJoinWithBannerImage() Adds a LEFT JOIN clause and with to the query using the BannerImage relation
55
 * @method     ChildBannersQuery rightJoinWithBannerImage() Adds a RIGHT JOIN clause and with to the query using the BannerImage relation
56
 * @method     ChildBannersQuery innerJoinWithBannerImage() Adds a INNER JOIN clause and with to the query using the BannerImage relation
57
 *
58
 * @method     ChildBannersQuery leftJoinBannersI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the BannersI18n relation
59
 * @method     ChildBannersQuery rightJoinBannersI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BannersI18n relation
60
 * @method     ChildBannersQuery innerJoinBannersI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the BannersI18n relation
61
 *
62
 * @method     ChildBannersQuery joinWithBannersI18n($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the BannersI18n relation
63
 *
64
 * @method     ChildBannersQuery leftJoinWithBannersI18n() Adds a LEFT JOIN clause and with to the query using the BannersI18n relation
65
 * @method     ChildBannersQuery rightJoinWithBannersI18n() Adds a RIGHT JOIN clause and with to the query using the BannersI18n relation
66
 * @method     ChildBannersQuery innerJoinWithBannersI18n() Adds a INNER JOIN clause and with to the query using the BannersI18n relation
67
 *
68
 * @method     \xbanners\models\BannerImageQuery|\xbanners\models\BannersI18nQuery endUse() Finalizes a secondary criteria and merges it with its primary Criteria
69
 *
70
 * @method     ChildBanners findOne(ConnectionInterface $con = null) Return the first ChildBanners matching the query
71
 * @method     ChildBanners findOneOrCreate(ConnectionInterface $con = null) Return the first ChildBanners matching the query, or a new ChildBanners object populated from the query conditions when no match is found
72
 *
73
 * @method     ChildBanners findOneById(int $id) Return the first ChildBanners filtered by the id column
74
 * @method     ChildBanners findOneByPlace(string $place) Return the first ChildBanners filtered by the place column
75
 * @method     ChildBanners findOneByWidth(int $width) Return the first ChildBanners filtered by the width column
76
 * @method     ChildBanners findOneByHeight(int $height) Return the first ChildBanners filtered by the height column
77
 * @method     ChildBanners findOneByEffects(string $effects) Return the first ChildBanners filtered by the effects column
78
 * @method     ChildBanners findOneByPageType(string $page_type) Return the first ChildBanners filtered by the page_type column *
79
80
 * @method     ChildBanners requirePk($key, ConnectionInterface $con = null) Return the ChildBanners by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
81
 * @method     ChildBanners requireOne(ConnectionInterface $con = null) Return the first ChildBanners matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
82
 *
83
 * @method     ChildBanners requireOneById(int $id) Return the first ChildBanners filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
84
 * @method     ChildBanners requireOneByPlace(string $place) Return the first ChildBanners filtered by the place column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
85
 * @method     ChildBanners requireOneByWidth(int $width) Return the first ChildBanners filtered by the width column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
86
 * @method     ChildBanners requireOneByHeight(int $height) Return the first ChildBanners filtered by the height column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
87
 * @method     ChildBanners requireOneByEffects(string $effects) Return the first ChildBanners filtered by the effects column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
88
 * @method     ChildBanners requireOneByPageType(string $page_type) Return the first ChildBanners filtered by the page_type column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
89
 *
90
 * @method     ChildBanners[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildBanners objects based on current ModelCriteria
91
 * @method     ChildBanners[]|ObjectCollection findById(int $id) Return ChildBanners objects filtered by the id column
92
 * @method     ChildBanners[]|ObjectCollection findByPlace(string $place) Return ChildBanners objects filtered by the place column
93
 * @method     ChildBanners[]|ObjectCollection findByWidth(int $width) Return ChildBanners objects filtered by the width column
94
 * @method     ChildBanners[]|ObjectCollection findByHeight(int $height) Return ChildBanners objects filtered by the height column
95
 * @method     ChildBanners[]|ObjectCollection findByEffects(string $effects) Return ChildBanners objects filtered by the effects column
96
 * @method     ChildBanners[]|ObjectCollection findByPageType(string $page_type) Return ChildBanners objects filtered by the page_type column
97
 * @method     ChildBanners[]|\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
98
 *
99
 */
0 ignored issues
show
introduced by
Additional blank lines found at end of doc comment
Loading history...
100
abstract class BannersQuery extends ModelCriteria
101
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
102
    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...
103
104
    /**
105
     * Initializes internal state of \xbanners\models\Base\BannersQuery object.
106
     *
107
     * @param     string $dbName The database name
108
     * @param     string $modelName The phpName of a model, e.g. 'Book'
109
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
110
     */
111
    public function __construct($dbName = 'Shop', $modelName = '\\xbanners\\models\\Banners', $modelAlias = null)
112
    {
113
        parent::__construct($dbName, $modelName, $modelAlias);
114
    }
115
116
    /**
117
     * Returns a new ChildBannersQuery object.
118
     *
119
     * @param     string $modelAlias The alias of a model in the query
120
     * @param     Criteria $criteria Optional Criteria to build the query from
121
     *
122
     * @return ChildBannersQuery
123
     */
124 View Code Duplication
    public static function create($modelAlias = null, Criteria $criteria = null)
125
    {
126
        if ($criteria instanceof ChildBannersQuery) {
127
            return $criteria;
128
        }
129
        $query = new ChildBannersQuery();
130
        if (null !== $modelAlias) {
131
            $query->setModelAlias($modelAlias);
132
        }
133
        if ($criteria instanceof Criteria) {
0 ignored issues
show
Bug introduced by
The class Propel\Runtime\ActiveQuery\Criteria does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
134
            $query->mergeWith($criteria);
135
        }
136
137
        return $query;
138
    }
139
140
    /**
141
     * Find object by primary key.
142
     * Propel uses the instance pool to skip the database if the object exists.
143
     * Go fast if the query is untouched.
144
     *
145
     * <code>
0 ignored issues
show
introduced by
Doc comment long description must start with a capital letter
Loading history...
146
     * $obj  = $c->findPk(12, $con);
147
     * </code>
148
     *
149
     * @param mixed $key Primary key to use for the query
150
     * @param ConnectionInterface $con an optional connection object
151
     *
152
     * @return ChildBanners|array|mixed the result, formatted by the current formatter
153
     */
154 View Code Duplication
    public function findPk($key, ConnectionInterface $con = null)
155
    {
156
        if ($key === null) {
157
            return null;
158
        }
159
160
        if ($con === null) {
161
            $con = Propel::getServiceContainer()->getReadConnection(BannersTableMap::DATABASE_NAME);
162
        }
163
164
        $this->basePreSelect($con);
165
166
        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...
167
            $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...
168
            || $this->selectColumns || $this->asColumns || $this->selectModifiers
169
            || $this->map || $this->having || $this->joins
170
        ) {
171
            return $this->findPkComplex($key, $con);
172
        }
173
174
        if ((null !== ($obj = BannersTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key)))) {
175
            // the object is already in the instance pool
176
            return $obj;
177
        }
178
179
        return $this->findPkSimple($key, $con);
180
    }
181
182
    /**
183
     * Find object by primary key using raw SQL to go fast.
184
     * Bypass doSelect() and the object formatter by using generated code.
185
     *
186
     * @param     mixed $key Primary key to use for the query
187
     * @param     ConnectionInterface $con A connection object
188
     *
189
     * @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...
190
     *
191
     * @return ChildBanners A model object, or null if the key is not found
0 ignored issues
show
Documentation introduced by
Should the return type not be ChildBanners|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...
192
     */
193 View Code Duplication
    protected function findPkSimple($key, ConnectionInterface $con)
194
    {
195
        $sql = 'SELECT id, place, width, height, effects, page_type FROM banners WHERE id = :p0';
196
        try {
197
            $stmt = $con->prepare($sql);
198
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
199
            $stmt->execute();
200
        } catch (Exception $e) {
201
            Propel::log($e->getMessage(), Propel::LOG_ERR);
202
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
203
        }
204
        $obj = null;
205
        if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
206
            /** @var ChildBanners $obj */
207
            $obj = new ChildBanners();
208
            $obj->hydrate($row);
209
            BannersTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key);
210
        }
211
        $stmt->closeCursor();
212
213
        return $obj;
214
    }
215
216
    /**
217
     * Find object by primary key.
218
     *
219
     * @param     mixed $key Primary key to use for the query
220
     * @param     ConnectionInterface $con A connection object
221
     *
222
     * @return ChildBanners|array|mixed the result, formatted by the current formatter
223
     */
224
    protected function findPkComplex($key, ConnectionInterface $con)
225
    {
226
        // As the query uses a PK condition, no limit(1) is necessary.
227
        $criteria = $this->isKeepQuery() ? clone $this : $this;
228
        $dataFetcher = $criteria
229
            ->filterByPrimaryKey($key)
230
            ->doSelect($con);
231
232
        return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
233
    }
234
235
    /**
236
     * Find objects by primary key
237
     * <code>
238
     * $objs = $c->findPks(array(12, 56, 832), $con);
239
     * </code>
240
     * @param     array $keys Primary keys to use for the query
241
     * @param     ConnectionInterface $con an optional connection object
242
     *
243
     * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
244
     */
245
    public function findPks($keys, ConnectionInterface $con = null)
246
    {
247
        if (null === $con) {
248
            $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
249
        }
250
        $this->basePreSelect($con);
251
        $criteria = $this->isKeepQuery() ? clone $this : $this;
252
        $dataFetcher = $criteria
253
            ->filterByPrimaryKeys($keys)
254
            ->doSelect($con);
255
256
        return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
257
    }
258
259
    /**
260
     * Filter the query by primary key
261
     *
262
     * @param     mixed $key Primary key to use for the query
263
     *
264
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
265
     */
266
    public function filterByPrimaryKey($key)
267
    {
268
269
        return $this->addUsingAlias(BannersTableMap::COL_ID, $key, Criteria::EQUAL);
270
    }
271
272
    /**
273
     * Filter the query by a list of primary keys
274
     *
275
     * @param     array $keys The list of primary key to use for the query
276
     *
277
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
278
     */
279
    public function filterByPrimaryKeys($keys)
280
    {
281
282
        return $this->addUsingAlias(BannersTableMap::COL_ID, $keys, Criteria::IN);
283
    }
284
285
    /**
286
     * Filter the query on the id column
287
     *
288
     * Example usage:
289
     * <code>
290
     * $query->filterById(1234); // WHERE id = 1234
291
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
292
     * $query->filterById(array('min' => 12)); // WHERE id > 12
293
     * </code>
294
     *
295
     * @param     mixed $id The value to use as filter.
296
     *              Use scalar values for equality.
297
     *              Use array values for in_array() equivalent.
298
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
299
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
300
     *
301
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
302
     */
303 View Code Duplication
    public function filterById($id = null, $comparison = null)
304
    {
305
        if (is_array($id)) {
306
            $useMinMax = false;
307
            if (isset($id['min'])) {
308
                $this->addUsingAlias(BannersTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL);
309
                $useMinMax = true;
310
            }
311
            if (isset($id['max'])) {
312
                $this->addUsingAlias(BannersTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL);
313
                $useMinMax = true;
314
            }
315
            if ($useMinMax) {
316
                return $this;
317
            }
318
            if (null === $comparison) {
319
                $comparison = Criteria::IN;
320
            }
321
        }
322
323
        return $this->addUsingAlias(BannersTableMap::COL_ID, $id, $comparison);
324
    }
325
326
    /**
327
     * Filter the query on the place column
328
     *
329
     * Example usage:
330
     * <code>
331
     * $query->filterByPlace('fooValue');   // WHERE place = 'fooValue'
332
     * $query->filterByPlace('%fooValue%'); // WHERE place LIKE '%fooValue%'
333
     * </code>
334
     *
335
     * @param     string $place The value to use as filter.
336
     *              Accepts wildcards (* and % trigger a LIKE)
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
337
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
338
     *
339
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
340
     */
341 View Code Duplication
    public function filterByPlace($place = null, $comparison = null)
342
    {
343
        if (null === $comparison) {
344
            if (is_array($place)) {
345
                $comparison = Criteria::IN;
346
            } elseif (preg_match('/[\%\*]/', $place)) {
347
                $place = str_replace('*', '%', $place);
348
                $comparison = Criteria::LIKE;
349
            }
350
        }
351
352
        return $this->addUsingAlias(BannersTableMap::COL_PLACE, $place, $comparison);
353
    }
354
355
    /**
356
     * Filter the query on the width column
357
     *
358
     * Example usage:
359
     * <code>
360
     * $query->filterByWidth(1234); // WHERE width = 1234
361
     * $query->filterByWidth(array(12, 34)); // WHERE width IN (12, 34)
362
     * $query->filterByWidth(array('min' => 12)); // WHERE width > 12
363
     * </code>
364
     *
365
     * @param     mixed $width The value to use as filter.
366
     *              Use scalar values for equality.
367
     *              Use array values for in_array() equivalent.
368
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
369
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
370
     *
371
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
372
     */
373 View Code Duplication
    public function filterByWidth($width = null, $comparison = null)
374
    {
375
        if (is_array($width)) {
376
            $useMinMax = false;
377
            if (isset($width['min'])) {
378
                $this->addUsingAlias(BannersTableMap::COL_WIDTH, $width['min'], Criteria::GREATER_EQUAL);
379
                $useMinMax = true;
380
            }
381
            if (isset($width['max'])) {
382
                $this->addUsingAlias(BannersTableMap::COL_WIDTH, $width['max'], Criteria::LESS_EQUAL);
383
                $useMinMax = true;
384
            }
385
            if ($useMinMax) {
386
                return $this;
387
            }
388
            if (null === $comparison) {
389
                $comparison = Criteria::IN;
390
            }
391
        }
392
393
        return $this->addUsingAlias(BannersTableMap::COL_WIDTH, $width, $comparison);
394
    }
395
396
    /**
397
     * Filter the query on the height column
398
     *
399
     * Example usage:
400
     * <code>
401
     * $query->filterByHeight(1234); // WHERE height = 1234
402
     * $query->filterByHeight(array(12, 34)); // WHERE height IN (12, 34)
403
     * $query->filterByHeight(array('min' => 12)); // WHERE height > 12
404
     * </code>
405
     *
406
     * @param     mixed $height The value to use as filter.
407
     *              Use scalar values for equality.
408
     *              Use array values for in_array() equivalent.
409
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
410
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
411
     *
412
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
413
     */
414 View Code Duplication
    public function filterByHeight($height = null, $comparison = null)
415
    {
416
        if (is_array($height)) {
417
            $useMinMax = false;
418
            if (isset($height['min'])) {
419
                $this->addUsingAlias(BannersTableMap::COL_HEIGHT, $height['min'], Criteria::GREATER_EQUAL);
420
                $useMinMax = true;
421
            }
422
            if (isset($height['max'])) {
423
                $this->addUsingAlias(BannersTableMap::COL_HEIGHT, $height['max'], Criteria::LESS_EQUAL);
424
                $useMinMax = true;
425
            }
426
            if ($useMinMax) {
427
                return $this;
428
            }
429
            if (null === $comparison) {
430
                $comparison = Criteria::IN;
431
            }
432
        }
433
434
        return $this->addUsingAlias(BannersTableMap::COL_HEIGHT, $height, $comparison);
435
    }
436
437
    /**
438
     * Filter the query on the effects column
439
     *
440
     * Example usage:
441
     * <code>
442
     * $query->filterByEffects('fooValue');   // WHERE effects = 'fooValue'
443
     * $query->filterByEffects('%fooValue%'); // WHERE effects LIKE '%fooValue%'
444
     * </code>
445
     *
446
     * @param     string $effects The value to use as filter.
447
     *              Accepts wildcards (* and % trigger a LIKE)
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
448
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
449
     *
450
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
451
     */
452 View Code Duplication
    public function filterByEffects($effects = null, $comparison = null)
453
    {
454
        if (null === $comparison) {
455
            if (is_array($effects)) {
456
                $comparison = Criteria::IN;
457
            } elseif (preg_match('/[\%\*]/', $effects)) {
458
                $effects = str_replace('*', '%', $effects);
459
                $comparison = Criteria::LIKE;
460
            }
461
        }
462
463
        return $this->addUsingAlias(BannersTableMap::COL_EFFECTS, $effects, $comparison);
464
    }
465
466
    /**
467
     * Filter the query on the page_type column
468
     *
469
     * Example usage:
470
     * <code>
471
     * $query->filterByPageType('fooValue');   // WHERE page_type = 'fooValue'
472
     * $query->filterByPageType('%fooValue%'); // WHERE page_type LIKE '%fooValue%'
473
     * </code>
474
     *
475
     * @param     string $pageType The value to use as filter.
476
     *              Accepts wildcards (* and % trigger a LIKE)
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
477
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
478
     *
479
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
480
     */
481 View Code Duplication
    public function filterByPageType($pageType = null, $comparison = null)
482
    {
483
        if (null === $comparison) {
484
            if (is_array($pageType)) {
485
                $comparison = Criteria::IN;
486
            } elseif (preg_match('/[\%\*]/', $pageType)) {
487
                $pageType = str_replace('*', '%', $pageType);
488
                $comparison = Criteria::LIKE;
489
            }
490
        }
491
492
        return $this->addUsingAlias(BannersTableMap::COL_PAGE_TYPE, $pageType, $comparison);
493
    }
494
495
    /**
496
     * Filter the query by a related \xbanners\models\BannerImage object
497
     *
498
     * @param \xbanners\models\BannerImage|ObjectCollection $bannerImage the related object to use as filter
499
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
500
     *
501
     * @return ChildBannersQuery The current query, for fluid interface
502
     */
503 View Code Duplication
    public function filterByBannerImage($bannerImage, $comparison = null)
504
    {
505
        if ($bannerImage instanceof \xbanners\models\BannerImage) {
506
            return $this
507
                ->addUsingAlias(BannersTableMap::COL_ID, $bannerImage->getBannerId(), $comparison);
508
        } elseif ($bannerImage instanceof ObjectCollection) {
0 ignored issues
show
Bug introduced by
The class Propel\Runtime\Collection\ObjectCollection does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
509
            return $this
510
                ->useBannerImageQuery()
511
                ->filterByPrimaryKeys($bannerImage->getPrimaryKeys())
512
                ->endUse();
513
        } else {
514
            throw new PropelException('filterByBannerImage() only accepts arguments of type \xbanners\models\BannerImage or Collection');
515
        }
516
    }
517
518
    /**
519
     * Adds a JOIN clause to the query using the BannerImage relation
520
     *
521
     * @param     string $relationAlias optional alias for the relation
522
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
523
     *
524
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
525
     */
526
    public function joinBannerImage($relationAlias = null, $joinType = Criteria::INNER_JOIN)
527
    {
528
        $tableMap = $this->getTableMap();
529
        $relationMap = $tableMap->getRelation('BannerImage');
530
531
        // create a ModelJoin object for this join
532
        $join = new ModelJoin();
533
        $join->setJoinType($joinType);
534
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
535
        if ($previousJoin = $this->getPreviousJoin()) {
536
            $join->setPreviousJoin($previousJoin);
537
        }
538
539
        // add the ModelJoin to the current object
540
        if ($relationAlias) {
541
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
542
            $this->addJoinObject($join, $relationAlias);
543
        } else {
544
            $this->addJoinObject($join, 'BannerImage');
545
        }
546
547
        return $this;
548
    }
549
550
    /**
551
     * Use the BannerImage relation BannerImage object
552
     *
553
     * @see useQuery()
554
     *
555
     * @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...
556
     *                                   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...
557
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
558
     *
559
     * @return \xbanners\models\BannerImageQuery A secondary query class using the current class as primary query
560
     */
561
    public function useBannerImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
562
    {
563
        return $this
564
            ->joinBannerImage($relationAlias, $joinType)
565
            ->useQuery($relationAlias ? $relationAlias : 'BannerImage', '\xbanners\models\BannerImageQuery');
566
    }
567
568
    /**
569
     * Filter the query by a related \xbanners\models\BannersI18n object
570
     *
571
     * @param \xbanners\models\BannersI18n|ObjectCollection $bannersI18n the related object to use as filter
572
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
573
     *
574
     * @return ChildBannersQuery The current query, for fluid interface
575
     */
576 View Code Duplication
    public function filterByBannersI18n($bannersI18n, $comparison = null)
577
    {
578
        if ($bannersI18n instanceof \xbanners\models\BannersI18n) {
579
            return $this
580
                ->addUsingAlias(BannersTableMap::COL_ID, $bannersI18n->getId(), $comparison);
581
        } elseif ($bannersI18n instanceof ObjectCollection) {
0 ignored issues
show
Bug introduced by
The class Propel\Runtime\Collection\ObjectCollection does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
582
            return $this
583
                ->useBannersI18nQuery()
584
                ->filterByPrimaryKeys($bannersI18n->getPrimaryKeys())
585
                ->endUse();
586
        } else {
587
            throw new PropelException('filterByBannersI18n() only accepts arguments of type \xbanners\models\BannersI18n or Collection');
588
        }
589
    }
590
591
    /**
592
     * Adds a JOIN clause to the query using the BannersI18n relation
593
     *
594
     * @param     string $relationAlias optional alias for the relation
595
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
596
     *
597
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
598
     */
599
    public function joinBannersI18n($relationAlias = null, $joinType = 'LEFT JOIN')
600
    {
601
        $tableMap = $this->getTableMap();
602
        $relationMap = $tableMap->getRelation('BannersI18n');
603
604
        // create a ModelJoin object for this join
605
        $join = new ModelJoin();
606
        $join->setJoinType($joinType);
607
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
608
        if ($previousJoin = $this->getPreviousJoin()) {
609
            $join->setPreviousJoin($previousJoin);
610
        }
611
612
        // add the ModelJoin to the current object
613
        if ($relationAlias) {
614
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
615
            $this->addJoinObject($join, $relationAlias);
616
        } else {
617
            $this->addJoinObject($join, 'BannersI18n');
618
        }
619
620
        return $this;
621
    }
622
623
    /**
624
     * Use the BannersI18n relation BannersI18n object
625
     *
626
     * @see useQuery()
627
     *
628
     * @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...
629
     *                                   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...
630
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
631
     *
632
     * @return \xbanners\models\BannersI18nQuery A secondary query class using the current class as primary query
633
     */
634
    public function useBannersI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
635
    {
636
        return $this
637
            ->joinBannersI18n($relationAlias, $joinType)
638
            ->useQuery($relationAlias ? $relationAlias : 'BannersI18n', '\xbanners\models\BannersI18nQuery');
639
    }
640
641
    /**
642
     * Exclude object from result
643
     *
644
     * @param   ChildBanners $banners Object to remove from the list of results
645
     *
646
     * @return $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
647
     */
648
    public function prune($banners = null)
649
    {
650
        if ($banners) {
651
            $this->addUsingAlias(BannersTableMap::COL_ID, $banners->getId(), Criteria::NOT_EQUAL);
652
        }
653
654
        return $this;
655
    }
656
657
    /**
658
     * Deletes all rows from the banners table.
659
     *
660
     * @param ConnectionInterface $con the connection to use
661
     * @return int The number of affected rows (if supported by underlying database driver).
662
     */
663
    public function doDeleteAll(ConnectionInterface $con = null)
664
    {
665
        if (null === $con) {
666
            $con = Propel::getServiceContainer()->getWriteConnection(BannersTableMap::DATABASE_NAME);
667
        }
668
669
        // use transaction because $criteria could contain info
670
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
671
        return $con->transaction(function () use ($con) {
672
            $affectedRows = 0; // initialize var to track total num of affected rows
673
            $affectedRows += $this->doOnDeleteCascade($con);
674
            $affectedRows += parent::doDeleteAll($con);
675
            // Because this db requires some delete cascade/set null emulation, we have to
676
            // clear the cached instance *after* the emulation has happened (since
677
            // instances get re-added by the select statement contained therein).
678
            BannersTableMap::clearInstancePool();
679
            BannersTableMap::clearRelatedInstancePool();
680
681
            return $affectedRows;
682
        });
683
    }
684
685
    /**
686
     * Performs a DELETE on the database based on the current ModelCriteria
687
     *
688
     * @param ConnectionInterface $con the connection to use
689
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
690
     *                         if supported by native driver or if emulated using Propel.
691
     * @throws PropelException Any exceptions caught during processing will be
692
     *                         rethrown wrapped into a PropelException.
0 ignored issues
show
introduced by
@throws tag comment must start with a capital letter
Loading history...
693
     */
694 View Code Duplication
    public function delete(ConnectionInterface $con = null)
695
    {
696
        if (null === $con) {
697
            $con = Propel::getServiceContainer()->getWriteConnection(BannersTableMap::DATABASE_NAME);
698
        }
699
700
        $criteria = $this;
701
702
        // Set the correct dbName
703
        $criteria->setDbName(BannersTableMap::DATABASE_NAME);
704
705
        // use transaction because $criteria could contain info
706
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
707
        return $con->transaction(function () use ($con, $criteria) {
708
            $affectedRows = 0; // initialize var to track total num of affected rows
709
710
            // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
711
            $c = clone $criteria;
712
            $affectedRows += $c->doOnDeleteCascade($con);
713
714
            BannersTableMap::removeInstanceFromPool($criteria);
715
716
            $affectedRows += ModelCriteria::delete($con);
717
            BannersTableMap::clearRelatedInstancePool();
718
719
            return $affectedRows;
720
        });
721
    }
722
723
    /**
724
     * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
725
     * feature (like MySQL or SQLite).
726
     *
727
     * This method is not very speedy because it must perform a query first to get
728
     * the implicated records and then perform the deletes by calling those Query classes.
729
     *
730
     * This method should be used within a transaction if possible.
731
     *
732
     * @param ConnectionInterface $con
733
     * @return int The number of affected rows (if supported by underlying database driver).
734
     */
735
    protected function doOnDeleteCascade(ConnectionInterface $con)
736
    {
737
        // initialize var to track total num of affected rows
738
        $affectedRows = 0;
739
740
        // first find the objects that are implicated by the $this
741
        $objects = ChildBannersQuery::create(null, $this)->find($con);
742
        foreach ($objects as $obj) {
743
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
744
745
            // delete related BannerImage objects
746
            $query = new \xbanners\models\BannerImageQuery;
0 ignored issues
show
Coding Style introduced by
Instantiating objects should always be done with parentheses.

The object instantiation should always have parentheses even if no arguments are passed:

new DateTime; // Bad
new DateTime(); // Good
Loading history...
747
748
            $query->add(BannerImageTableMap::COL_BANNER_ID, $obj->getId());
749
            $affectedRows += $query->delete($con);
750
751
            // delete related BannersI18n objects
752
            $query = new \xbanners\models\BannersI18nQuery;
0 ignored issues
show
Coding Style introduced by
Instantiating objects should always be done with parentheses.

The object instantiation should always have parentheses even if no arguments are passed:

new DateTime; // Bad
new DateTime(); // Good
Loading history...
753
754
            $query->add(BannersI18nTableMap::COL_ID, $obj->getId());
755
            $affectedRows += $query->delete($con);
756
        }
757
758
        return $affectedRows;
759
    }
760
761
    // i18n behavior
762
763
    /**
764
     * Adds a JOIN clause to the query using the i18n relation
765
     *
766
     * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
767
     * @param     string $relationAlias optional alias for the relation
768
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
769
     *
770
     * @return    ChildBannersQuery The current query, for fluid interface
771
     */
772 View Code Duplication
    public function joinI18n($locale = 'ru', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
773
    {
774
        $relationName = $relationAlias ? $relationAlias : 'BannersI18n';
775
776
        return $this
777
            ->joinBannersI18n($relationAlias, $joinType)
778
            ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
779
    }
780
781
    /**
782
     * Adds a JOIN clause to the query and hydrates the related I18n object.
783
     * Shortcut for $c->joinI18n($locale)->with()
784
     *
785
     * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
786
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
787
     *
788
     * @return    $this|ChildBannersQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
789
     */
790 View Code Duplication
    public function joinWithI18n($locale = 'ru', $joinType = Criteria::LEFT_JOIN)
791
    {
792
        $this
793
            ->joinI18n($locale, null, $joinType)
794
            ->with('BannersI18n');
795
        $this->with['BannersI18n']->setIsWithOneToMany(false);
796
797
        return $this;
798
    }
799
800
    /**
801
     * Use the I18n relation query object
802
     *
803
     * @see       useQuery()
804
     *
805
     * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
0 ignored issues
show
introduced by
Paramater tags must be defined first in a doc commment
Loading history...
806
     * @param     string $relationAlias optional alias for the relation
807
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
808
     *
809
     * @return    ChildBannersI18nQuery A secondary query class using the current class as primary query
810
     */
811
    public function useI18nQuery($locale = 'ru', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
812
    {
813
        return $this
814
            ->joinI18n($locale, $relationAlias, $joinType)
815
            ->useQuery($relationAlias ? $relationAlias : 'BannersI18n', '\xbanners\models\BannersI18nQuery');
816
    }
817
818
} // BannersQuery
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...
819