Completed
Branch master (691237)
by dima
02:39
created

User::save()   C

Complexity

Conditions 8
Paths 3

Size

Total Lines 34
Code Lines 23

Duplication

Lines 34
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 34
loc 34
rs 5.3846
cc 8
eloc 23
nc 3
nop 1
1
<?php
2
3
namespace Models\User\Base;
4
5
use \DateTime;
6
use \Exception;
7
use \PDO;
8
use Models\User\UserQuery as ChildUserQuery;
9
use Models\User\Map\UserTableMap;
10
use Propel\Runtime\Propel;
11
use Propel\Runtime\ActiveQuery\Criteria;
12
use Propel\Runtime\ActiveQuery\ModelCriteria;
13
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
14
use Propel\Runtime\Collection\Collection;
15
use Propel\Runtime\Connection\ConnectionInterface;
16
use Propel\Runtime\Exception\BadMethodCallException;
17
use Propel\Runtime\Exception\LogicException;
18
use Propel\Runtime\Exception\PropelException;
19
use Propel\Runtime\Map\TableMap;
20
use Propel\Runtime\Parser\AbstractParser;
21
use Propel\Runtime\Util\PropelDateTime;
22
23
/**
24
 * Base class that represents a row from the 'users' table.
25
 *
26
 *
27
 *
28
* @package    propel.generator.Models.User.Base
29
*/
30
abstract class User implements ActiveRecordInterface
31
{
32
    /**
33
     * TableMap class name
34
     */
35
    const TABLE_MAP = '\\Models\\User\\Map\\UserTableMap';
36
37
38
    /**
39
     * attribute to determine if this object has previously been saved.
40
     * @var boolean
41
     */
42
    protected $new = true;
43
44
    /**
45
     * attribute to determine whether this object has been deleted.
46
     * @var boolean
47
     */
48
    protected $deleted = false;
49
50
    /**
51
     * The columns that have been modified in current object.
52
     * Tracking modified columns allows us to only update modified columns.
53
     * @var array
54
     */
55
    protected $modifiedColumns = array();
56
57
    /**
58
     * The (virtual) columns that are added at runtime
59
     * The formatters can add supplementary columns based on a resultset
60
     * @var array
61
     */
62
    protected $virtualColumns = array();
63
64
    /**
65
     * The value for the id field.
66
     * @var        int
67
     */
68
    protected $id;
69
70
    /**
71
     * The value for the name field.
72
     * @var        string
73
     */
74
    protected $name;
75
76
    /**
77
     * The value for the email field.
78
     * @var        string
79
     */
80
    protected $email;
81
82
    /**
83
     * The value for the password field.
84
     * @var        string
85
     */
86
    protected $password;
87
88
    /**
89
     * The value for the remember_token field.
90
     * @var        string
91
     */
92
    protected $remember_token;
93
94
    /**
95
     * The value for the created_at field.
96
     * @var        \DateTime
97
     */
98
    protected $created_at;
99
100
    /**
101
     * The value for the updated_at field.
102
     * @var        \DateTime
103
     */
104
    protected $updated_at;
105
106
    /**
107
     * Flag to prevent endless save loop, if this object is referenced
108
     * by another object which falls in this transaction.
109
     *
110
     * @var boolean
111
     */
112
    protected $alreadyInSave = false;
113
114
    /**
115
     * Initializes internal state of Models\User\Base\User object.
116
     */
117
    public function __construct()
118
    {
119
    }
120
121
    /**
122
     * Returns whether the object has been modified.
123
     *
124
     * @return boolean True if the object has been modified.
125
     */
126
    public function isModified()
127
    {
128
        return !!$this->modifiedColumns;
129
    }
130
131
    /**
132
     * Has specified column been modified?
133
     *
134
     * @param  string  $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
135
     * @return boolean True if $col has been modified.
136
     */
137
    public function isColumnModified($col)
138
    {
139
        return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->modifiedColumns of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
140
    }
141
142
    /**
143
     * Get the columns that have been modified in this object.
144
     * @return array A unique list of the modified column names for this object.
145
     */
146
    public function getModifiedColumns()
147
    {
148
        return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
149
    }
150
151
    /**
152
     * Returns whether the object has ever been saved.  This will
153
     * be false, if the object was retrieved from storage or was created
154
     * and then saved.
155
     *
156
     * @return boolean true, if the object has never been persisted.
157
     */
158
    public function isNew()
159
    {
160
        return $this->new;
161
    }
162
163
    /**
164
     * Setter for the isNew attribute.  This method will be called
165
     * by Propel-generated children and objects.
166
     *
167
     * @param boolean $b the state of the object.
168
     */
169
    public function setNew($b)
170
    {
171
        $this->new = (boolean) $b;
172
    }
173
174
    /**
175
     * Whether this object has been deleted.
176
     * @return boolean The deleted state of this object.
177
     */
178
    public function isDeleted()
179
    {
180
        return $this->deleted;
181
    }
182
183
    /**
184
     * Specify whether this object has been deleted.
185
     * @param  boolean $b The deleted state of this object.
186
     * @return void
187
     */
188
    public function setDeleted($b)
189
    {
190
        $this->deleted = (boolean) $b;
191
    }
192
193
    /**
194
     * Sets the modified state for the object to be false.
195
     * @param  string $col If supplied, only the specified column is reset.
196
     * @return void
197
     */
198 View Code Duplication
    public function resetModified($col = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
199
    {
200
        if (null !== $col) {
201
            if (isset($this->modifiedColumns[$col])) {
202
                unset($this->modifiedColumns[$col]);
203
            }
204
        } else {
205
            $this->modifiedColumns = array();
206
        }
207
    }
208
209
    /**
210
     * Compares this with another <code>User</code> instance.  If
211
     * <code>obj</code> is an instance of <code>User</code>, delegates to
212
     * <code>equals(User)</code>.  Otherwise, returns <code>false</code>.
213
     *
214
     * @param  mixed   $obj The object to compare to.
215
     * @return boolean Whether equal to the object specified.
216
     */
217 View Code Duplication
    public function equals($obj)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
218
    {
219
        if (!$obj instanceof static) {
220
            return false;
221
        }
222
223
        if ($this === $obj) {
224
            return true;
225
        }
226
227
        if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) {
228
            return false;
229
        }
230
231
        return $this->getPrimaryKey() === $obj->getPrimaryKey();
232
    }
233
234
    /**
235
     * Get the associative array of the virtual columns in this object
236
     *
237
     * @return array
238
     */
239
    public function getVirtualColumns()
240
    {
241
        return $this->virtualColumns;
242
    }
243
244
    /**
245
     * Checks the existence of a virtual column in this object
246
     *
247
     * @param  string  $name The virtual column name
248
     * @return boolean
249
     */
250
    public function hasVirtualColumn($name)
251
    {
252
        return array_key_exists($name, $this->virtualColumns);
253
    }
254
255
    /**
256
     * Get the value of a virtual column in this object
257
     *
258
     * @param  string $name The virtual column name
259
     * @return mixed
260
     *
261
     * @throws PropelException
262
     */
263 View Code Duplication
    public function getVirtualColumn($name)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
264
    {
265
        if (!$this->hasVirtualColumn($name)) {
266
            throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
267
        }
268
269
        return $this->virtualColumns[$name];
270
    }
271
272
    /**
273
     * Set the value of a virtual column in this object
274
     *
275
     * @param string $name  The virtual column name
276
     * @param mixed  $value The value to give to the virtual column
277
     *
278
     * @return $this|User The current object, for fluid interface
279
     */
280
    public function setVirtualColumn($name, $value)
281
    {
282
        $this->virtualColumns[$name] = $value;
283
284
        return $this;
285
    }
286
287
    /**
288
     * Logs a message using Propel::log().
289
     *
290
     * @param  string  $msg
291
     * @param  int     $priority One of the Propel::LOG_* logging levels
292
     * @return boolean
293
     */
294
    protected function log($msg, $priority = Propel::LOG_INFO)
295
    {
296
        return Propel::log(get_class($this) . ': ' . $msg, $priority);
297
    }
298
299
    /**
300
     * Export the current object properties to a string, using a given parser format
301
     * <code>
302
     * $book = BookQuery::create()->findPk(9012);
303
     * echo $book->exportTo('JSON');
304
     *  => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
305
     * </code>
306
     *
307
     * @param  mixed   $parser                 A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
308
     * @param  boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
309
     * @return string  The exported data
310
     */
311 View Code Duplication
    public function exportTo($parser, $includeLazyLoadColumns = true)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
312
    {
313
        if (!$parser instanceof AbstractParser) {
314
            $parser = AbstractParser::getParser($parser);
315
        }
316
317
        return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
0 ignored issues
show
Unused Code introduced by
The call to User::toArray() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
Bug introduced by
It seems like $this->toArray(\Propel\R...Columns, array(), true) targeting Models\User\Base\User::toArray() can also be of type string; however, Propel\Runtime\Parser\AbstractParser::fromArray() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
318
    }
319
320
    /**
321
     * Clean up internal collections prior to serializing
322
     * Avoids recursive loops that turn into segmentation faults when serializing
323
     */
324
    public function __sleep()
325
    {
326
        $this->clearAllReferences();
0 ignored issues
show
Unused Code introduced by
The call to the method Models\User\Base\User::clearAllReferences() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
327
328
        return array_keys(get_object_vars($this));
329
    }
330
331
    /**
332
     * Get the [id] column value.
333
     *
334
     * @return int
335
     */
336
    public function getId()
337
    {
338
        return $this->id;
339
    }
340
341
    /**
342
     * Get the [name] column value.
343
     *
344
     * @return string
345
     */
346
    public function getName()
347
    {
348
        return $this->name;
349
    }
350
351
    /**
352
     * Get the [email] column value.
353
     *
354
     * @return string
355
     */
356
    public function getEmail()
357
    {
358
        return $this->email;
359
    }
360
361
    /**
362
     * Get the [password] column value.
363
     *
364
     * @return string
365
     */
366
    public function getPassword()
367
    {
368
        return $this->password;
369
    }
370
371
    /**
372
     * Get the [remember_token] column value.
373
     *
374
     * @return string
375
     */
376
    public function getRememberToken()
377
    {
378
        return $this->remember_token;
379
    }
380
381
    /**
382
     * Get the [optionally formatted] temporal [created_at] column value.
383
     *
384
     *
385
     * @param      string $format The date/time format string (either date()-style or strftime()-style).
386
     *                            If format is NULL, then the raw DateTime object will be returned.
387
     *
388
     * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
389
     *
390
     * @throws PropelException - if unable to parse/validate the date/time value.
391
     */
392 View Code Duplication
    public function getCreatedAt($format = NULL)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
393
    {
394
        if ($format === null) {
395
            return $this->created_at;
396
        } else {
397
            return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
398
        }
399
    }
400
401
    /**
402
     * Get the [optionally formatted] temporal [updated_at] column value.
403
     *
404
     *
405
     * @param      string $format The date/time format string (either date()-style or strftime()-style).
406
     *                            If format is NULL, then the raw DateTime object will be returned.
407
     *
408
     * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
409
     *
410
     * @throws PropelException - if unable to parse/validate the date/time value.
411
     */
412 View Code Duplication
    public function getUpdatedAt($format = NULL)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
413
    {
414
        if ($format === null) {
415
            return $this->updated_at;
416
        } else {
417
            return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
418
        }
419
    }
420
421
    /**
422
     * Set the value of [id] column.
423
     *
424
     * @param int $v new value
425
     * @return $this|\Models\User\User The current object (for fluent API support)
426
     */
427 View Code Duplication
    public function setId($v)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
428
    {
429
        if ($v !== null) {
430
            $v = (int) $v;
431
        }
432
433
        if ($this->id !== $v) {
434
            $this->id = $v;
435
            $this->modifiedColumns[UserTableMap::COL_ID] = true;
436
        }
437
438
        return $this;
439
    } // setId()
440
441
    /**
442
     * Set the value of [name] column.
443
     *
444
     * @param string $v new value
445
     * @return $this|\Models\User\User The current object (for fluent API support)
446
     */
447 View Code Duplication
    public function setName($v)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
448
    {
449
        if ($v !== null) {
450
            $v = (string) $v;
451
        }
452
453
        if ($this->name !== $v) {
454
            $this->name = $v;
455
            $this->modifiedColumns[UserTableMap::COL_NAME] = true;
456
        }
457
458
        return $this;
459
    } // setName()
460
461
    /**
462
     * Set the value of [email] column.
463
     *
464
     * @param string $v new value
465
     * @return $this|\Models\User\User The current object (for fluent API support)
466
     */
467 View Code Duplication
    public function setEmail($v)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
468
    {
469
        if ($v !== null) {
470
            $v = (string) $v;
471
        }
472
473
        if ($this->email !== $v) {
474
            $this->email = $v;
475
            $this->modifiedColumns[UserTableMap::COL_EMAIL] = true;
476
        }
477
478
        return $this;
479
    } // setEmail()
480
481
    /**
482
     * Set the value of [password] column.
483
     *
484
     * @param string $v new value
485
     * @return $this|\Models\User\User The current object (for fluent API support)
486
     */
487 View Code Duplication
    public function setPassword($v)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
488
    {
489
        if ($v !== null) {
490
            $v = (string) $v;
491
        }
492
493
        if ($this->password !== $v) {
494
            $this->password = $v;
495
            $this->modifiedColumns[UserTableMap::COL_PASSWORD] = true;
496
        }
497
498
        return $this;
499
    } // setPassword()
500
501
    /**
502
     * Set the value of [remember_token] column.
503
     *
504
     * @param string $v new value
505
     * @return $this|\Models\User\User The current object (for fluent API support)
506
     */
507 View Code Duplication
    public function setRememberToken($v)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
508
    {
509
        if ($v !== null) {
510
            $v = (string) $v;
511
        }
512
513
        if ($this->remember_token !== $v) {
514
            $this->remember_token = $v;
515
            $this->modifiedColumns[UserTableMap::COL_REMEMBER_TOKEN] = true;
516
        }
517
518
        return $this;
519
    } // setRememberToken()
520
521
    /**
522
     * Sets the value of [created_at] column to a normalized version of the date/time value specified.
523
     *
524
     * @param  mixed $v string, integer (timestamp), or \DateTime value.
525
     *               Empty strings are treated as NULL.
526
     * @return $this|\Models\User\User The current object (for fluent API support)
527
     */
528 View Code Duplication
    public function setCreatedAt($v)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
529
    {
530
        $dt = PropelDateTime::newInstance($v, null, 'DateTime');
531
        if ($this->created_at !== null || $dt !== null) {
532
            if ($this->created_at === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->created_at->format("Y-m-d H:i:s")) {
533
                $this->created_at = $dt === null ? null : clone $dt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $dt === null ? null : clone $dt can also be of type false. However, the property $created_at is declared as type object<DateTime>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
534
                $this->modifiedColumns[UserTableMap::COL_CREATED_AT] = true;
535
            }
536
        } // if either are not null
537
538
        return $this;
539
    } // setCreatedAt()
540
541
    /**
542
     * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
543
     *
544
     * @param  mixed $v string, integer (timestamp), or \DateTime value.
545
     *               Empty strings are treated as NULL.
546
     * @return $this|\Models\User\User The current object (for fluent API support)
547
     */
548 View Code Duplication
    public function setUpdatedAt($v)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
549
    {
550
        $dt = PropelDateTime::newInstance($v, null, 'DateTime');
551
        if ($this->updated_at !== null || $dt !== null) {
552
            if ($this->updated_at === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->updated_at->format("Y-m-d H:i:s")) {
553
                $this->updated_at = $dt === null ? null : clone $dt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $dt === null ? null : clone $dt can also be of type false. However, the property $updated_at is declared as type object<DateTime>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
554
                $this->modifiedColumns[UserTableMap::COL_UPDATED_AT] = true;
555
            }
556
        } // if either are not null
557
558
        return $this;
559
    } // setUpdatedAt()
560
561
    /**
562
     * Indicates whether the columns in this object are only set to default values.
563
     *
564
     * This method can be used in conjunction with isModified() to indicate whether an object is both
565
     * modified _and_ has some values set which are non-default.
566
     *
567
     * @return boolean Whether the columns in this object are only been set with default values.
568
     */
569
    public function hasOnlyDefaultValues()
570
    {
571
        // otherwise, everything was equal, so return TRUE
572
        return true;
573
    } // hasOnlyDefaultValues()
574
575
    /**
576
     * Hydrates (populates) the object variables with values from the database resultset.
577
     *
578
     * An offset (0-based "start column") is specified so that objects can be hydrated
579
     * with a subset of the columns in the resultset rows.  This is needed, for example,
580
     * for results of JOIN queries where the resultset row includes columns from two or
581
     * more tables.
582
     *
583
     * @param array   $row       The row returned by DataFetcher->fetch().
584
     * @param int     $startcol  0-based offset column which indicates which restultset column to start with.
585
     * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
586
     * @param string  $indexType The index type of $row. Mostly DataFetcher->getIndexType().
587
                                  One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
588
     *                            TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
589
     *
590
     * @return int             next starting column
591
     * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
592
     */
593
    public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
594
    {
595
        try {
596
597
            $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : UserTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
598
            $this->id = (null !== $col) ? (int) $col : null;
599
600
            $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : UserTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)];
601
            $this->name = (null !== $col) ? (string) $col : null;
602
603
            $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : UserTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)];
604
            $this->email = (null !== $col) ? (string) $col : null;
605
606
            $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : UserTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)];
607
            $this->password = (null !== $col) ? (string) $col : null;
608
609
            $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : UserTableMap::translateFieldName('RememberToken', TableMap::TYPE_PHPNAME, $indexType)];
610
            $this->remember_token = (null !== $col) ? (string) $col : null;
611
612
            $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : UserTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
613
            if ($col === '0000-00-00 00:00:00') {
614
                $col = null;
615
            }
616
            $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null;
617
618
            $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : UserTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
619
            if ($col === '0000-00-00 00:00:00') {
620
                $col = null;
621
            }
622
            $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null;
623
            $this->resetModified();
624
625
            $this->setNew(false);
626
627
            if ($rehydrate) {
628
                $this->ensureConsistency();
629
            }
630
631
            return $startcol + 7; // 7 = UserTableMap::NUM_HYDRATE_COLUMNS.
632
633
        } catch (Exception $e) {
634
            throw new PropelException(sprintf('Error populating %s object', '\\Models\\User\\User'), 0, $e);
635
        }
636
    }
637
638
    /**
639
     * Checks and repairs the internal consistency of the object.
640
     *
641
     * This method is executed after an already-instantiated object is re-hydrated
642
     * from the database.  It exists to check any foreign keys to make sure that
643
     * the objects related to the current object are correct based on foreign key.
644
     *
645
     * You can override this method in the stub class, but you should always invoke
646
     * the base method from the overridden method (i.e. parent::ensureConsistency()),
647
     * in case your model changes.
648
     *
649
     * @throws PropelException
650
     */
651
    public function ensureConsistency()
652
    {
653
    } // ensureConsistency
654
655
    /**
656
     * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
657
     *
658
     * This will only work if the object has been saved and has a valid primary key set.
659
     *
660
     * @param      boolean $deep (optional) Whether to also de-associated any related objects.
661
     * @param      ConnectionInterface $con (optional) The ConnectionInterface connection to use.
662
     * @return void
663
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
664
     */
665 View Code Duplication
    public function reload($deep = false, ConnectionInterface $con = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
666
    {
667
        if ($this->isDeleted()) {
668
            throw new PropelException("Cannot reload a deleted object.");
669
        }
670
671
        if ($this->isNew()) {
672
            throw new PropelException("Cannot reload an unsaved object.");
673
        }
674
675
        if ($con === null) {
676
            $con = Propel::getServiceContainer()->getReadConnection(UserTableMap::DATABASE_NAME);
677
        }
678
679
        // We don't need to alter the object instance pool; we're just modifying this instance
680
        // already in the pool.
681
682
        $dataFetcher = ChildUserQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Propel\Runtime\ActiveQuery\BaseModelCriteria as the method find() does only exist in the following sub-classes of Propel\Runtime\ActiveQuery\BaseModelCriteria: Models\Task\Base\TaskQuery, Models\Task\TaskQuery, Models\User\Base\UserQuery, Models\User\UserQuery, Propel\Runtime\ActiveQuery\ModelCriteria. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
683
        $row = $dataFetcher->fetch();
684
        $dataFetcher->close();
685
        if (!$row) {
686
            throw new PropelException('Cannot find matching row in the database to reload object values.');
687
        }
688
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
689
690
        if ($deep) {  // also de-associate any related objects?
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
691
692
        } // if (deep)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
693
    }
694
695
    /**
696
     * Removes this object from datastore and sets delete attribute.
697
     *
698
     * @param      ConnectionInterface $con
699
     * @return void
700
     * @throws PropelException
701
     * @see User::setDeleted()
702
     * @see User::isDeleted()
703
     */
704 View Code Duplication
    public function delete(ConnectionInterface $con = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
705
    {
706
        if ($this->isDeleted()) {
707
            throw new PropelException("This object has already been deleted.");
708
        }
709
710
        if ($con === null) {
711
            $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME);
712
        }
713
714
        $con->transaction(function () use ($con) {
715
            $deleteQuery = ChildUserQuery::create()
716
                ->filterByPrimaryKey($this->getPrimaryKey());
717
            $ret = $this->preDelete($con);
718
            if ($ret) {
719
                $deleteQuery->delete($con);
720
                $this->postDelete($con);
721
                $this->setDeleted(true);
722
            }
723
        });
724
    }
725
726
    /**
727
     * Persists this object to the database.
728
     *
729
     * If the object is new, it inserts it; otherwise an update is performed.
730
     * All modified related objects will also be persisted in the doSave()
731
     * method.  This method wraps all precipitate database operations in a
732
     * single transaction.
733
     *
734
     * @param      ConnectionInterface $con
735
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
736
     * @throws PropelException
737
     * @see doSave()
738
     */
739 View Code Duplication
    public function save(ConnectionInterface $con = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
740
    {
741
        if ($this->isDeleted()) {
742
            throw new PropelException("You cannot save an object that has been deleted.");
743
        }
744
745
        if ($con === null) {
746
            $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME);
747
        }
748
749
        return $con->transaction(function () use ($con) {
750
            $isInsert = $this->isNew();
751
            $ret = $this->preSave($con);
752
            if ($isInsert) {
753
                $ret = $ret && $this->preInsert($con);
754
            } else {
755
                $ret = $ret && $this->preUpdate($con);
756
            }
757
            if ($ret) {
758
                $affectedRows = $this->doSave($con);
759
                if ($isInsert) {
760
                    $this->postInsert($con);
761
                } else {
762
                    $this->postUpdate($con);
763
                }
764
                $this->postSave($con);
765
                UserTableMap::addInstanceToPool($this);
766
            } else {
767
                $affectedRows = 0;
768
            }
769
770
            return $affectedRows;
771
        });
772
    }
773
774
    /**
775
     * Performs the work of inserting or updating the row in the database.
776
     *
777
     * If the object is new, it inserts it; otherwise an update is performed.
778
     * All related objects are also updated in this method.
779
     *
780
     * @param      ConnectionInterface $con
781
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
782
     * @throws PropelException
783
     * @see save()
784
     */
785 View Code Duplication
    protected function doSave(ConnectionInterface $con)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
786
    {
787
        $affectedRows = 0; // initialize var to track total num of affected rows
788
        if (!$this->alreadyInSave) {
789
            $this->alreadyInSave = true;
790
791
            if ($this->isNew() || $this->isModified()) {
792
                // persist changes
793
                if ($this->isNew()) {
794
                    $this->doInsert($con);
795
                    $affectedRows += 1;
796
                } else {
797
                    $affectedRows += $this->doUpdate($con);
798
                }
799
                $this->resetModified();
800
            }
801
802
            $this->alreadyInSave = false;
803
804
        }
805
806
        return $affectedRows;
807
    } // doSave()
808
809
    /**
810
     * Insert the row in the database.
811
     *
812
     * @param      ConnectionInterface $con
813
     *
814
     * @throws PropelException
815
     * @see doSave()
816
     */
817
    protected function doInsert(ConnectionInterface $con)
818
    {
819
        $modifiedColumns = array();
820
        $index = 0;
821
822
        $this->modifiedColumns[UserTableMap::COL_ID] = true;
823
        if (null !== $this->id) {
824
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserTableMap::COL_ID . ')');
825
        }
826
827
         // check the columns in natural order for more readable SQL queries
828
        if ($this->isColumnModified(UserTableMap::COL_ID)) {
829
            $modifiedColumns[':p' . $index++]  = 'id';
830
        }
831
        if ($this->isColumnModified(UserTableMap::COL_NAME)) {
832
            $modifiedColumns[':p' . $index++]  = 'name';
833
        }
834
        if ($this->isColumnModified(UserTableMap::COL_EMAIL)) {
835
            $modifiedColumns[':p' . $index++]  = 'email';
836
        }
837
        if ($this->isColumnModified(UserTableMap::COL_PASSWORD)) {
838
            $modifiedColumns[':p' . $index++]  = 'password';
839
        }
840
        if ($this->isColumnModified(UserTableMap::COL_REMEMBER_TOKEN)) {
841
            $modifiedColumns[':p' . $index++]  = 'remember_token';
842
        }
843
        if ($this->isColumnModified(UserTableMap::COL_CREATED_AT)) {
844
            $modifiedColumns[':p' . $index++]  = 'created_at';
845
        }
846
        if ($this->isColumnModified(UserTableMap::COL_UPDATED_AT)) {
847
            $modifiedColumns[':p' . $index++]  = 'updated_at';
848
        }
849
850
        $sql = sprintf(
851
            'INSERT INTO users (%s) VALUES (%s)',
852
            implode(', ', $modifiedColumns),
853
            implode(', ', array_keys($modifiedColumns))
854
        );
855
856
        try {
857
            $stmt = $con->prepare($sql);
858
            foreach ($modifiedColumns as $identifier => $columnName) {
859
                switch ($columnName) {
860
                    case 'id':
861
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
862
                        break;
863
                    case 'name':
864
                        $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
865
                        break;
866
                    case 'email':
867
                        $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR);
868
                        break;
869
                    case 'password':
870
                        $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR);
871
                        break;
872
                    case 'remember_token':
873
                        $stmt->bindValue($identifier, $this->remember_token, PDO::PARAM_STR);
874
                        break;
875 View Code Duplication
                    case 'created_at':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
876
                        $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
877
                        break;
878 View Code Duplication
                    case 'updated_at':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
879
                        $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
880
                        break;
881
                }
882
            }
883
            $stmt->execute();
884
        } catch (Exception $e) {
885
            Propel::log($e->getMessage(), Propel::LOG_ERR);
886
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
887
        }
888
889
        try {
890
            $pk = $con->lastInsertId();
891
        } catch (Exception $e) {
892
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
893
        }
894
        $this->setId($pk);
895
896
        $this->setNew(false);
897
    }
898
899
    /**
900
     * Update the row in the database.
901
     *
902
     * @param      ConnectionInterface $con
903
     *
904
     * @return Integer Number of updated rows
905
     * @see doSave()
906
     */
907
    protected function doUpdate(ConnectionInterface $con)
908
    {
909
        $selectCriteria = $this->buildPkeyCriteria();
910
        $valuesCriteria = $this->buildCriteria();
911
912
        return $selectCriteria->doUpdate($valuesCriteria, $con);
0 ignored issues
show
Documentation introduced by
$valuesCriteria is of type object<Propel\Runtime\ActiveQuery\Criteria>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
913
    }
914
915
    /**
916
     * Retrieves a field from the object by name passed in as a string.
917
     *
918
     * @param      string $name name
919
     * @param      string $type The type of fieldname the $name is of:
920
     *                     one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
921
     *                     TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
922
     *                     Defaults to TableMap::TYPE_PHPNAME.
923
     * @return mixed Value of field.
924
     */
925 View Code Duplication
    public function getByName($name, $type = TableMap::TYPE_PHPNAME)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
926
    {
927
        $pos = UserTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
928
        $field = $this->getByPosition($pos);
929
930
        return $field;
931
    }
932
933
    /**
934
     * Retrieves a field from the object by Position as specified in the xml schema.
935
     * Zero-based.
936
     *
937
     * @param      int $pos position in xml schema
938
     * @return mixed Value of field at $pos
939
     */
940
    public function getByPosition($pos)
941
    {
942
        switch ($pos) {
943
            case 0:
944
                return $this->getId();
945
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
946
            case 1:
947
                return $this->getName();
948
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
949
            case 2:
950
                return $this->getEmail();
951
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
952
            case 3:
953
                return $this->getPassword();
954
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
955
            case 4:
956
                return $this->getRememberToken();
957
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
958
            case 5:
959
                return $this->getCreatedAt();
960
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
961
            case 6:
962
                return $this->getUpdatedAt();
963
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
964
            default:
965
                return null;
966
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
967
        } // switch()
968
    }
969
970
    /**
971
     * Exports the object as an array.
972
     *
973
     * You can specify the key type of the array by passing one of the class
974
     * type constants.
975
     *
976
     * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
977
     *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
978
     *                    Defaults to TableMap::TYPE_PHPNAME.
979
     * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
980
     * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
981
     *
982
     * @return array an associative array containing the field names (as keys) and field values
983
     */
984
    public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
0 ignored issues
show
Unused Code introduced by
The parameter $includeLazyLoadColumns is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
985
    {
986
987
        if (isset($alreadyDumpedObjects['User'][$this->hashCode()])) {
988
            return '*RECURSION*';
989
        }
990
        $alreadyDumpedObjects['User'][$this->hashCode()] = true;
991
        $keys = UserTableMap::getFieldNames($keyType);
992
        $result = array(
993
            $keys[0] => $this->getId(),
994
            $keys[1] => $this->getName(),
995
            $keys[2] => $this->getEmail(),
996
            $keys[3] => $this->getPassword(),
997
            $keys[4] => $this->getRememberToken(),
998
            $keys[5] => $this->getCreatedAt(),
999
            $keys[6] => $this->getUpdatedAt(),
1000
        );
1001
1002
        $utc = new \DateTimeZone('utc');
1003 View Code Duplication
        if ($result[$keys[5]] instanceof \DateTime) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1004
            // When changing timezone we don't want to change existing instances
1005
            $dateTime = clone $result[$keys[5]];
1006
            $result[$keys[5]] = $dateTime->setTimezone($utc)->format('Y-m-d\TH:i:s\Z');
1007
        }
1008
1009 View Code Duplication
        if ($result[$keys[6]] instanceof \DateTime) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1010
            // When changing timezone we don't want to change existing instances
1011
            $dateTime = clone $result[$keys[6]];
1012
            $result[$keys[6]] = $dateTime->setTimezone($utc)->format('Y-m-d\TH:i:s\Z');
1013
        }
1014
1015
        $virtualColumns = $this->virtualColumns;
1016
        foreach ($virtualColumns as $key => $virtualColumn) {
1017
            $result[$key] = $virtualColumn;
1018
        }
1019
1020
1021
        return $result;
1022
    }
1023
1024
    /**
1025
     * Sets a field from the object by name passed in as a string.
1026
     *
1027
     * @param  string $name
1028
     * @param  mixed  $value field value
1029
     * @param  string $type The type of fieldname the $name is of:
1030
     *                one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
1031
     *                TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1032
     *                Defaults to TableMap::TYPE_PHPNAME.
1033
     * @return $this|\Models\User\User
1034
     */
1035
    public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
1036
    {
1037
        $pos = UserTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
1038
1039
        return $this->setByPosition($pos, $value);
1040
    }
1041
1042
    /**
1043
     * Sets a field from the object by Position as specified in the xml schema.
1044
     * Zero-based.
1045
     *
1046
     * @param  int $pos position in xml schema
1047
     * @param  mixed $value field value
1048
     * @return $this|\Models\User\User
1049
     */
1050
    public function setByPosition($pos, $value)
1051
    {
1052
        switch ($pos) {
1053
            case 0:
1054
                $this->setId($value);
1055
                break;
1056
            case 1:
1057
                $this->setName($value);
1058
                break;
1059
            case 2:
1060
                $this->setEmail($value);
1061
                break;
1062
            case 3:
1063
                $this->setPassword($value);
1064
                break;
1065
            case 4:
1066
                $this->setRememberToken($value);
1067
                break;
1068
            case 5:
1069
                $this->setCreatedAt($value);
1070
                break;
1071
            case 6:
1072
                $this->setUpdatedAt($value);
1073
                break;
1074
        } // switch()
1075
1076
        return $this;
1077
    }
1078
1079
    /**
1080
     * Populates the object using an array.
1081
     *
1082
     * This is particularly useful when populating an object from one of the
1083
     * request arrays (e.g. $_POST).  This method goes through the column
1084
     * names, checking to see whether a matching key exists in populated
1085
     * array. If so the setByName() method is called for that column.
1086
     *
1087
     * You can specify the key type of the array by additionally passing one
1088
     * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
1089
     * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1090
     * The default key type is the column's TableMap::TYPE_PHPNAME.
1091
     *
1092
     * @param      array  $arr     An array to populate the object from.
1093
     * @param      string $keyType The type of keys the array uses.
1094
     * @return void
1095
     */
1096
    public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
1097
    {
1098
        $keys = UserTableMap::getFieldNames($keyType);
1099
1100
        if (array_key_exists($keys[0], $arr)) {
1101
            $this->setId($arr[$keys[0]]);
1102
        }
1103
        if (array_key_exists($keys[1], $arr)) {
1104
            $this->setName($arr[$keys[1]]);
1105
        }
1106
        if (array_key_exists($keys[2], $arr)) {
1107
            $this->setEmail($arr[$keys[2]]);
1108
        }
1109
        if (array_key_exists($keys[3], $arr)) {
1110
            $this->setPassword($arr[$keys[3]]);
1111
        }
1112
        if (array_key_exists($keys[4], $arr)) {
1113
            $this->setRememberToken($arr[$keys[4]]);
1114
        }
1115
        if (array_key_exists($keys[5], $arr)) {
1116
            $this->setCreatedAt($arr[$keys[5]]);
1117
        }
1118
        if (array_key_exists($keys[6], $arr)) {
1119
            $this->setUpdatedAt($arr[$keys[6]]);
1120
        }
1121
    }
1122
1123
     /**
1124
     * Populate the current object from a string, using a given parser format
1125
     * <code>
1126
     * $book = new Book();
1127
     * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
1128
     * </code>
1129
     *
1130
     * You can specify the key type of the array by additionally passing one
1131
     * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
1132
     * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1133
     * The default key type is the column's TableMap::TYPE_PHPNAME.
1134
     *
1135
     * @param mixed $parser A AbstractParser instance,
1136
     *                       or a format name ('XML', 'YAML', 'JSON', 'CSV')
1137
     * @param string $data The source data to import from
1138
     * @param string $keyType The type of keys the array uses.
1139
     *
1140
     * @return $this|\Models\User\User The current object, for fluid interface
1141
     */
1142 View Code Duplication
    public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1143
    {
1144
        if (!$parser instanceof AbstractParser) {
1145
            $parser = AbstractParser::getParser($parser);
1146
        }
1147
1148
        $this->fromArray($parser->toArray($data), $keyType);
1149
1150
        return $this;
1151
    }
1152
1153
    /**
1154
     * Build a Criteria object containing the values of all modified columns in this object.
1155
     *
1156
     * @return Criteria The Criteria object containing all modified values.
1157
     */
1158
    public function buildCriteria()
1159
    {
1160
        $criteria = new Criteria(UserTableMap::DATABASE_NAME);
1161
1162
        if ($this->isColumnModified(UserTableMap::COL_ID)) {
1163
            $criteria->add(UserTableMap::COL_ID, $this->id);
1164
        }
1165
        if ($this->isColumnModified(UserTableMap::COL_NAME)) {
1166
            $criteria->add(UserTableMap::COL_NAME, $this->name);
1167
        }
1168
        if ($this->isColumnModified(UserTableMap::COL_EMAIL)) {
1169
            $criteria->add(UserTableMap::COL_EMAIL, $this->email);
1170
        }
1171
        if ($this->isColumnModified(UserTableMap::COL_PASSWORD)) {
1172
            $criteria->add(UserTableMap::COL_PASSWORD, $this->password);
1173
        }
1174
        if ($this->isColumnModified(UserTableMap::COL_REMEMBER_TOKEN)) {
1175
            $criteria->add(UserTableMap::COL_REMEMBER_TOKEN, $this->remember_token);
1176
        }
1177
        if ($this->isColumnModified(UserTableMap::COL_CREATED_AT)) {
1178
            $criteria->add(UserTableMap::COL_CREATED_AT, $this->created_at);
1179
        }
1180
        if ($this->isColumnModified(UserTableMap::COL_UPDATED_AT)) {
1181
            $criteria->add(UserTableMap::COL_UPDATED_AT, $this->updated_at);
1182
        }
1183
1184
        return $criteria;
1185
    }
1186
1187
    /**
1188
     * Builds a Criteria object containing the primary key for this object.
1189
     *
1190
     * Unlike buildCriteria() this method includes the primary key values regardless
1191
     * of whether or not they have been modified.
1192
     *
1193
     * @throws LogicException if no primary key is defined
1194
     *
1195
     * @return Criteria The Criteria object containing value(s) for primary key(s).
1196
     */
1197
    public function buildPkeyCriteria()
1198
    {
1199
        $criteria = ChildUserQuery::create();
1200
        $criteria->add(UserTableMap::COL_ID, $this->id);
1201
1202
        return $criteria;
1203
    }
1204
1205
    /**
1206
     * If the primary key is not null, return the hashcode of the
1207
     * primary key. Otherwise, return the hash code of the object.
1208
     *
1209
     * @return int Hashcode
1210
     */
1211 View Code Duplication
    public function hashCode()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1212
    {
1213
        $validPk = null !== $this->getId();
1214
1215
        $validPrimaryKeyFKs = 0;
1216
        $primaryKeyFKs = [];
1217
1218
        if ($validPk) {
1219
            return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE));
1220
        } elseif ($validPrimaryKeyFKs) {
1221
            return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE));
1222
        }
1223
1224
        return spl_object_hash($this);
1225
    }
1226
1227
    /**
1228
     * Returns the primary key for this object (row).
1229
     * @return int
1230
     */
1231
    public function getPrimaryKey()
1232
    {
1233
        return $this->getId();
1234
    }
1235
1236
    /**
1237
     * Generic method to set the primary key (id column).
1238
     *
1239
     * @param       int $key Primary key.
1240
     * @return void
1241
     */
1242
    public function setPrimaryKey($key)
1243
    {
1244
        $this->setId($key);
1245
    }
1246
1247
    /**
1248
     * Returns true if the primary key for this object is null.
1249
     * @return boolean
1250
     */
1251
    public function isPrimaryKeyNull()
1252
    {
1253
        return null === $this->getId();
1254
    }
1255
1256
    /**
1257
     * Sets contents of passed object to values from current object.
1258
     *
1259
     * If desired, this method can also make copies of all associated (fkey referrers)
1260
     * objects.
1261
     *
1262
     * @param      object $copyObj An object of \Models\User\User (or compatible) type.
1263
     * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1264
     * @param      boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1265
     * @throws PropelException
1266
     */
1267
    public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
0 ignored issues
show
Unused Code introduced by
The parameter $deepCopy is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1268
    {
1269
        $copyObj->setName($this->getName());
1270
        $copyObj->setEmail($this->getEmail());
1271
        $copyObj->setPassword($this->getPassword());
1272
        $copyObj->setRememberToken($this->getRememberToken());
1273
        $copyObj->setCreatedAt($this->getCreatedAt());
1274
        $copyObj->setUpdatedAt($this->getUpdatedAt());
1275
        if ($makeNew) {
1276
            $copyObj->setNew(true);
1277
            $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1278
        }
1279
    }
1280
1281
    /**
1282
     * Makes a copy of this object that will be inserted as a new row in table when saved.
1283
     * It creates a new object filling in the simple attributes, but skipping any primary
1284
     * keys that are defined for the table.
1285
     *
1286
     * If desired, this method can also make copies of all associated (fkey referrers)
1287
     * objects.
1288
     *
1289
     * @param  boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1290
     * @return \Models\User\User Clone of current object.
1291
     * @throws PropelException
1292
     */
1293 View Code Duplication
    public function copy($deepCopy = false)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1294
    {
1295
        // we use get_class(), because this might be a subclass
1296
        $clazz = get_class($this);
1297
        $copyObj = new $clazz();
1298
        $this->copyInto($copyObj, $deepCopy);
1299
1300
        return $copyObj;
1301
    }
1302
1303
    /**
1304
     * Clears the current object, sets all attributes to their default values and removes
1305
     * outgoing references as well as back-references (from other objects to this one. Results probably in a database
1306
     * change of those foreign objects when you call `save` there).
1307
     */
1308
    public function clear()
1309
    {
1310
        $this->id = null;
1311
        $this->name = null;
1312
        $this->email = null;
1313
        $this->password = null;
1314
        $this->remember_token = null;
1315
        $this->created_at = null;
1316
        $this->updated_at = null;
1317
        $this->alreadyInSave = false;
1318
        $this->clearAllReferences();
0 ignored issues
show
Unused Code introduced by
The call to the method Models\User\Base\User::clearAllReferences() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
1319
        $this->resetModified();
1320
        $this->setNew(true);
1321
        $this->setDeleted(false);
1322
    }
1323
1324
    /**
1325
     * Resets all references and back-references to other model objects or collections of model objects.
1326
     *
1327
     * This method is used to reset all php object references (not the actual reference in the database).
1328
     * Necessary for object serialisation.
1329
     *
1330
     * @param      boolean $deep Whether to also clear the references on all referrer objects.
1331
     */
1332
    public function clearAllReferences($deep = false)
1333
    {
1334
        if ($deep) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
1335
        } // if ($deep)
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1336
1337
    }
1338
1339
    /**
1340
     * Return the string representation of this object
1341
     *
1342
     * @return string
1343
     */
1344
    public function __toString()
1345
    {
1346
        return (string) $this->exportTo(UserTableMap::DEFAULT_STRING_FORMAT);
1347
    }
1348
1349
    /**
1350
     * Code to be run before persisting the object
1351
     * @param  ConnectionInterface $con
1352
     * @return boolean
1353
     */
1354
    public function preSave(ConnectionInterface $con = null)
0 ignored issues
show
Unused Code introduced by
The parameter $con is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1355
    {
1356
        return true;
1357
    }
1358
1359
    /**
1360
     * Code to be run after persisting the object
1361
     * @param ConnectionInterface $con
1362
     */
1363
    public function postSave(ConnectionInterface $con = null)
0 ignored issues
show
Unused Code introduced by
The parameter $con is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1364
    {
1365
1366
    }
1367
1368
    /**
1369
     * Code to be run before inserting to database
1370
     * @param  ConnectionInterface $con
1371
     * @return boolean
1372
     */
1373
    public function preInsert(ConnectionInterface $con = null)
0 ignored issues
show
Unused Code introduced by
The parameter $con is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1374
    {
1375
        return true;
1376
    }
1377
1378
    /**
1379
     * Code to be run after inserting to database
1380
     * @param ConnectionInterface $con
1381
     */
1382
    public function postInsert(ConnectionInterface $con = null)
0 ignored issues
show
Unused Code introduced by
The parameter $con is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1383
    {
1384
1385
    }
1386
1387
    /**
1388
     * Code to be run before updating the object in database
1389
     * @param  ConnectionInterface $con
1390
     * @return boolean
1391
     */
1392
    public function preUpdate(ConnectionInterface $con = null)
0 ignored issues
show
Unused Code introduced by
The parameter $con is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1393
    {
1394
        return true;
1395
    }
1396
1397
    /**
1398
     * Code to be run after updating the object in database
1399
     * @param ConnectionInterface $con
1400
     */
1401
    public function postUpdate(ConnectionInterface $con = null)
0 ignored issues
show
Unused Code introduced by
The parameter $con is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1402
    {
1403
1404
    }
1405
1406
    /**
1407
     * Code to be run before deleting the object in database
1408
     * @param  ConnectionInterface $con
1409
     * @return boolean
1410
     */
1411
    public function preDelete(ConnectionInterface $con = null)
0 ignored issues
show
Unused Code introduced by
The parameter $con is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1412
    {
1413
        return true;
1414
    }
1415
1416
    /**
1417
     * Code to be run after deleting the object in database
1418
     * @param ConnectionInterface $con
1419
     */
1420
    public function postDelete(ConnectionInterface $con = null)
0 ignored issues
show
Unused Code introduced by
The parameter $con is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1421
    {
1422
1423
    }
1424
1425
1426
    /**
1427
     * Derived method to catches calls to undefined methods.
1428
     *
1429
     * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
1430
     * Allows to define default __call() behavior if you overwrite __call()
1431
     *
1432
     * @param string $name
1433
     * @param mixed  $params
1434
     *
1435
     * @return array|string
1436
     */
1437 View Code Duplication
    public function __call($name, $params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1438
    {
1439
        if (0 === strpos($name, 'get')) {
1440
            $virtualColumn = substr($name, 3);
1441
            if ($this->hasVirtualColumn($virtualColumn)) {
1442
                return $this->getVirtualColumn($virtualColumn);
1443
            }
1444
1445
            $virtualColumn = lcfirst($virtualColumn);
1446
            if ($this->hasVirtualColumn($virtualColumn)) {
1447
                return $this->getVirtualColumn($virtualColumn);
1448
            }
1449
        }
1450
1451
        if (0 === strpos($name, 'from')) {
1452
            $format = substr($name, 4);
1453
1454
            return $this->importFrom($format, reset($params));
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->importFrom...ormat, reset($params)); (Models\User\Base\User) is incompatible with the return type documented by Models\User\Base\User::__call of type array|string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
1455
        }
1456
1457
        if (0 === strpos($name, 'to')) {
1458
            $format = substr($name, 2);
1459
            $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
1460
1461
            return $this->exportTo($format, $includeLazyLoadColumns);
1462
        }
1463
1464
        throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
1465
    }
1466
1467
}
1468