Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Player 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 Player, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 36 | abstract class Player implements ActiveRecordInterface |
||
| 37 | { |
||
| 38 | /** |
||
| 39 | * TableMap class name |
||
| 40 | */ |
||
| 41 | const TABLE_MAP = '\\eXpansion\\Framework\\PlayersBundle\\Model\\Map\\PlayerTableMap'; |
||
| 42 | |||
| 43 | |||
| 44 | /** |
||
| 45 | * attribute to determine if this object has previously been saved. |
||
| 46 | * @var boolean |
||
| 47 | */ |
||
| 48 | protected $new = true; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * attribute to determine whether this object has been deleted. |
||
| 52 | * @var boolean |
||
| 53 | */ |
||
| 54 | protected $deleted = false; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * The columns that have been modified in current object. |
||
| 58 | * Tracking modified columns allows us to only update modified columns. |
||
| 59 | * @var array |
||
| 60 | */ |
||
| 61 | protected $modifiedColumns = array(); |
||
| 62 | |||
| 63 | /** |
||
| 64 | * The (virtual) columns that are added at runtime |
||
| 65 | * The formatters can add supplementary columns based on a resultset |
||
| 66 | * @var array |
||
| 67 | */ |
||
| 68 | protected $virtualColumns = array(); |
||
| 69 | |||
| 70 | /** |
||
| 71 | * The value for the id field. |
||
| 72 | * |
||
| 73 | * @var int |
||
| 74 | */ |
||
| 75 | protected $id; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * The value for the login field. |
||
| 79 | * |
||
| 80 | * @var string |
||
| 81 | */ |
||
| 82 | protected $login; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * The value for the nickname field. |
||
| 86 | * |
||
| 87 | * @var string |
||
| 88 | */ |
||
| 89 | protected $nickname; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * The value for the nickname_stripped field. |
||
| 93 | * |
||
| 94 | * @var string |
||
| 95 | */ |
||
| 96 | protected $nickname_stripped; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * The value for the path field. |
||
| 100 | * |
||
| 101 | * @var string |
||
| 102 | */ |
||
| 103 | protected $path; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * The value for the wins field. |
||
| 107 | * |
||
| 108 | * @var int |
||
| 109 | */ |
||
| 110 | protected $wins; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * The value for the online_time field. |
||
| 114 | * |
||
| 115 | * @var int |
||
| 116 | */ |
||
| 117 | protected $online_time; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * The value for the last_online field. |
||
| 121 | * |
||
| 122 | * @var DateTime |
||
| 123 | */ |
||
| 124 | protected $last_online; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * @var ObjectCollection|Record[] Collection to store aggregation of Record objects. |
||
| 128 | */ |
||
| 129 | protected $collRecords; |
||
| 130 | protected $collRecordsPartial; |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Flag to prevent endless save loop, if this object is referenced |
||
| 134 | * by another object which falls in this transaction. |
||
| 135 | * |
||
| 136 | * @var boolean |
||
| 137 | */ |
||
| 138 | protected $alreadyInSave = false; |
||
| 139 | |||
| 140 | /** |
||
| 141 | * An array of objects scheduled for deletion. |
||
| 142 | * @var ObjectCollection|Record[] |
||
| 143 | */ |
||
| 144 | protected $recordsScheduledForDeletion = null; |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Initializes internal state of eXpansion\Framework\PlayersBundle\Model\Base\Player object. |
||
| 148 | */ |
||
| 149 | public function __construct() |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Returns whether the object has been modified. |
||
| 155 | * |
||
| 156 | * @return boolean True if the object has been modified. |
||
| 157 | */ |
||
| 158 | public function isModified() |
||
| 162 | |||
| 163 | /** |
||
| 164 | * Has specified column been modified? |
||
| 165 | * |
||
| 166 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
| 167 | * @return boolean True if $col has been modified. |
||
| 168 | */ |
||
| 169 | public function isColumnModified($col) |
||
| 173 | |||
| 174 | /** |
||
| 175 | * Get the columns that have been modified in this object. |
||
| 176 | * @return array A unique list of the modified column names for this object. |
||
| 177 | */ |
||
| 178 | public function getModifiedColumns() |
||
| 182 | |||
| 183 | /** |
||
| 184 | * Returns whether the object has ever been saved. This will |
||
| 185 | * be false, if the object was retrieved from storage or was created |
||
| 186 | * and then saved. |
||
| 187 | * |
||
| 188 | * @return boolean true, if the object has never been persisted. |
||
| 189 | */ |
||
| 190 | public function isNew() |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Setter for the isNew attribute. This method will be called |
||
| 197 | * by Propel-generated children and objects. |
||
| 198 | * |
||
| 199 | * @param boolean $b the state of the object. |
||
| 200 | */ |
||
| 201 | public function setNew($b) |
||
| 205 | |||
| 206 | /** |
||
| 207 | * Whether this object has been deleted. |
||
| 208 | * @return boolean The deleted state of this object. |
||
| 209 | */ |
||
| 210 | public function isDeleted() |
||
| 214 | |||
| 215 | /** |
||
| 216 | * Specify whether this object has been deleted. |
||
| 217 | * @param boolean $b The deleted state of this object. |
||
| 218 | * @return void |
||
| 219 | */ |
||
| 220 | public function setDeleted($b) |
||
| 224 | |||
| 225 | /** |
||
| 226 | * Sets the modified state for the object to be false. |
||
| 227 | * @param string $col If supplied, only the specified column is reset. |
||
| 228 | * @return void |
||
| 229 | */ |
||
| 230 | View Code Duplication | public function resetModified($col = null) |
|
| 240 | |||
| 241 | /** |
||
| 242 | * Compares this with another <code>Player</code> instance. If |
||
| 243 | * <code>obj</code> is an instance of <code>Player</code>, delegates to |
||
| 244 | * <code>equals(Player)</code>. Otherwise, returns <code>false</code>. |
||
| 245 | * |
||
| 246 | * @param mixed $obj The object to compare to. |
||
| 247 | * @return boolean Whether equal to the object specified. |
||
| 248 | */ |
||
| 249 | View Code Duplication | public function equals($obj) |
|
| 265 | |||
| 266 | /** |
||
| 267 | * Get the associative array of the virtual columns in this object |
||
| 268 | * |
||
| 269 | * @return array |
||
| 270 | */ |
||
| 271 | public function getVirtualColumns() |
||
| 275 | |||
| 276 | /** |
||
| 277 | * Checks the existence of a virtual column in this object |
||
| 278 | * |
||
| 279 | * @param string $name The virtual column name |
||
| 280 | * @return boolean |
||
| 281 | */ |
||
| 282 | public function hasVirtualColumn($name) |
||
| 286 | |||
| 287 | /** |
||
| 288 | * Get the value of a virtual column in this object |
||
| 289 | * |
||
| 290 | * @param string $name The virtual column name |
||
| 291 | * @return mixed |
||
| 292 | * |
||
| 293 | * @throws PropelException |
||
| 294 | */ |
||
| 295 | View Code Duplication | public function getVirtualColumn($name) |
|
| 303 | |||
| 304 | /** |
||
| 305 | * Set the value of a virtual column in this object |
||
| 306 | * |
||
| 307 | * @param string $name The virtual column name |
||
| 308 | * @param mixed $value The value to give to the virtual column |
||
| 309 | * |
||
| 310 | * @return $this|Player The current object, for fluid interface |
||
| 311 | */ |
||
| 312 | public function setVirtualColumn($name, $value) |
||
| 318 | |||
| 319 | /** |
||
| 320 | * Logs a message using Propel::log(). |
||
| 321 | * |
||
| 322 | * @param string $msg |
||
| 323 | * @param int $priority One of the Propel::LOG_* logging levels |
||
| 324 | * @return boolean |
||
| 325 | */ |
||
| 326 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
| 330 | |||
| 331 | /** |
||
| 332 | * Export the current object properties to a string, using a given parser format |
||
| 333 | * <code> |
||
| 334 | * $book = BookQuery::create()->findPk(9012); |
||
| 335 | * echo $book->exportTo('JSON'); |
||
| 336 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 337 | * </code> |
||
| 338 | * |
||
| 339 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 340 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
| 341 | * @return string The exported data |
||
| 342 | */ |
||
| 343 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 351 | |||
| 352 | /** |
||
| 353 | * Clean up internal collections prior to serializing |
||
| 354 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
| 355 | */ |
||
| 356 | View Code Duplication | public function __sleep() |
|
| 370 | |||
| 371 | /** |
||
| 372 | * Get the [id] column value. |
||
| 373 | * |
||
| 374 | * @return int |
||
| 375 | */ |
||
| 376 | public function getId() |
||
| 380 | |||
| 381 | /** |
||
| 382 | * Get the [login] column value. |
||
| 383 | * |
||
| 384 | * @return string |
||
| 385 | */ |
||
| 386 | public function getLogin() |
||
| 390 | |||
| 391 | /** |
||
| 392 | * Get the [nickname] column value. |
||
| 393 | * |
||
| 394 | * @return string |
||
| 395 | */ |
||
| 396 | public function getNickname() |
||
| 400 | |||
| 401 | /** |
||
| 402 | * Get the [nickname_stripped] column value. |
||
| 403 | * |
||
| 404 | * @return string |
||
| 405 | */ |
||
| 406 | public function getNicknameStripped() |
||
| 410 | |||
| 411 | /** |
||
| 412 | * Get the [path] column value. |
||
| 413 | * |
||
| 414 | * @return string |
||
| 415 | */ |
||
| 416 | public function getPath() |
||
| 420 | |||
| 421 | /** |
||
| 422 | * Get the [wins] column value. |
||
| 423 | * |
||
| 424 | * @return int |
||
| 425 | */ |
||
| 426 | public function getWins() |
||
| 430 | |||
| 431 | /** |
||
| 432 | * Get the [online_time] column value. |
||
| 433 | * |
||
| 434 | * @return int |
||
| 435 | */ |
||
| 436 | public function getOnlineTime() |
||
| 440 | |||
| 441 | /** |
||
| 442 | * Get the [optionally formatted] temporal [last_online] column value. |
||
| 443 | * |
||
| 444 | * |
||
| 445 | * @param string $format The date/time format string (either date()-style or strftime()-style). |
||
| 446 | * If format is NULL, then the raw DateTime object will be returned. |
||
| 447 | * |
||
| 448 | * @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 |
||
| 449 | * |
||
| 450 | * @throws PropelException - if unable to parse/validate the date/time value. |
||
| 451 | */ |
||
| 452 | public function getLastOnline($format = NULL) |
||
| 460 | |||
| 461 | /** |
||
| 462 | * Set the value of [id] column. |
||
| 463 | * |
||
| 464 | * @param int $v new value |
||
| 465 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object (for fluent API support) |
||
| 466 | */ |
||
| 467 | View Code Duplication | public function setId($v) |
|
| 480 | |||
| 481 | /** |
||
| 482 | * Set the value of [login] column. |
||
| 483 | * |
||
| 484 | * @param string $v new value |
||
| 485 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object (for fluent API support) |
||
| 486 | */ |
||
| 487 | View Code Duplication | public function setLogin($v) |
|
| 500 | |||
| 501 | /** |
||
| 502 | * Set the value of [nickname] column. |
||
| 503 | * |
||
| 504 | * @param string $v new value |
||
| 505 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object (for fluent API support) |
||
| 506 | */ |
||
| 507 | View Code Duplication | public function setNickname($v) |
|
| 520 | |||
| 521 | /** |
||
| 522 | * Set the value of [nickname_stripped] column. |
||
| 523 | * |
||
| 524 | * @param string $v new value |
||
| 525 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object (for fluent API support) |
||
| 526 | */ |
||
| 527 | View Code Duplication | public function setNicknameStripped($v) |
|
| 540 | |||
| 541 | /** |
||
| 542 | * Set the value of [path] column. |
||
| 543 | * |
||
| 544 | * @param string $v new value |
||
| 545 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object (for fluent API support) |
||
| 546 | */ |
||
| 547 | View Code Duplication | public function setPath($v) |
|
| 560 | |||
| 561 | /** |
||
| 562 | * Set the value of [wins] column. |
||
| 563 | * |
||
| 564 | * @param int $v new value |
||
| 565 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object (for fluent API support) |
||
| 566 | */ |
||
| 567 | View Code Duplication | public function setWins($v) |
|
| 580 | |||
| 581 | /** |
||
| 582 | * Set the value of [online_time] column. |
||
| 583 | * |
||
| 584 | * @param int $v new value |
||
| 585 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object (for fluent API support) |
||
| 586 | */ |
||
| 587 | View Code Duplication | public function setOnlineTime($v) |
|
| 600 | |||
| 601 | /** |
||
| 602 | * Sets the value of [last_online] column to a normalized version of the date/time value specified. |
||
| 603 | * |
||
| 604 | * @param mixed $v string, integer (timestamp), or \DateTimeInterface value. |
||
| 605 | * Empty strings are treated as NULL. |
||
| 606 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object (for fluent API support) |
||
| 607 | */ |
||
| 608 | View Code Duplication | public function setLastOnline($v) |
|
| 620 | |||
| 621 | /** |
||
| 622 | * Indicates whether the columns in this object are only set to default values. |
||
| 623 | * |
||
| 624 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
| 625 | * modified _and_ has some values set which are non-default. |
||
| 626 | * |
||
| 627 | * @return boolean Whether the columns in this object are only been set with default values. |
||
| 628 | */ |
||
| 629 | public function hasOnlyDefaultValues() |
||
| 634 | |||
| 635 | /** |
||
| 636 | * Hydrates (populates) the object variables with values from the database resultset. |
||
| 637 | * |
||
| 638 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
| 639 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
| 640 | * for results of JOIN queries where the resultset row includes columns from two or |
||
| 641 | * more tables. |
||
| 642 | * |
||
| 643 | * @param array $row The row returned by DataFetcher->fetch(). |
||
| 644 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
| 645 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
| 646 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
| 647 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 648 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 649 | * |
||
| 650 | * @return int next starting column |
||
| 651 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
| 652 | */ |
||
| 653 | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
||
| 697 | |||
| 698 | /** |
||
| 699 | * Checks and repairs the internal consistency of the object. |
||
| 700 | * |
||
| 701 | * This method is executed after an already-instantiated object is re-hydrated |
||
| 702 | * from the database. It exists to check any foreign keys to make sure that |
||
| 703 | * the objects related to the current object are correct based on foreign key. |
||
| 704 | * |
||
| 705 | * You can override this method in the stub class, but you should always invoke |
||
| 706 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
| 707 | * in case your model changes. |
||
| 708 | * |
||
| 709 | * @throws PropelException |
||
| 710 | */ |
||
| 711 | public function ensureConsistency() |
||
| 714 | |||
| 715 | /** |
||
| 716 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
| 717 | * |
||
| 718 | * This will only work if the object has been saved and has a valid primary key set. |
||
| 719 | * |
||
| 720 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
| 721 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
| 722 | * @return void |
||
| 723 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
| 724 | */ |
||
| 725 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
| 756 | |||
| 757 | /** |
||
| 758 | * Removes this object from datastore and sets delete attribute. |
||
| 759 | * |
||
| 760 | * @param ConnectionInterface $con |
||
| 761 | * @return void |
||
| 762 | * @throws PropelException |
||
| 763 | * @see Player::setDeleted() |
||
| 764 | * @see Player::isDeleted() |
||
| 765 | */ |
||
| 766 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 787 | |||
| 788 | /** |
||
| 789 | * Persists this object to the database. |
||
| 790 | * |
||
| 791 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 792 | * All modified related objects will also be persisted in the doSave() |
||
| 793 | * method. This method wraps all precipitate database operations in a |
||
| 794 | * single transaction. |
||
| 795 | * |
||
| 796 | * @param ConnectionInterface $con |
||
| 797 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 798 | * @throws PropelException |
||
| 799 | * @see doSave() |
||
| 800 | */ |
||
| 801 | public function save(ConnectionInterface $con = null) |
||
| 835 | |||
| 836 | /** |
||
| 837 | * Performs the work of inserting or updating the row in the database. |
||
| 838 | * |
||
| 839 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 840 | * All related objects are also updated in this method. |
||
| 841 | * |
||
| 842 | * @param ConnectionInterface $con |
||
| 843 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 844 | * @throws PropelException |
||
| 845 | * @see save() |
||
| 846 | */ |
||
| 847 | protected function doSave(ConnectionInterface $con) |
||
| 888 | |||
| 889 | /** |
||
| 890 | * Insert the row in the database. |
||
| 891 | * |
||
| 892 | * @param ConnectionInterface $con |
||
| 893 | * |
||
| 894 | * @throws PropelException |
||
| 895 | * @see doSave() |
||
| 896 | */ |
||
| 897 | protected function doInsert(ConnectionInterface $con) |
||
| 984 | |||
| 985 | /** |
||
| 986 | * Update the row in the database. |
||
| 987 | * |
||
| 988 | * @param ConnectionInterface $con |
||
| 989 | * |
||
| 990 | * @return Integer Number of updated rows |
||
| 991 | * @see doSave() |
||
| 992 | */ |
||
| 993 | protected function doUpdate(ConnectionInterface $con) |
||
| 1000 | |||
| 1001 | /** |
||
| 1002 | * Retrieves a field from the object by name passed in as a string. |
||
| 1003 | * |
||
| 1004 | * @param string $name name |
||
| 1005 | * @param string $type The type of fieldname the $name is of: |
||
| 1006 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1007 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1008 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1009 | * @return mixed Value of field. |
||
| 1010 | */ |
||
| 1011 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 1018 | |||
| 1019 | /** |
||
| 1020 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
| 1021 | * Zero-based. |
||
| 1022 | * |
||
| 1023 | * @param int $pos position in xml schema |
||
| 1024 | * @return mixed Value of field at $pos |
||
| 1025 | */ |
||
| 1026 | public function getByPosition($pos) |
||
| 1058 | |||
| 1059 | /** |
||
| 1060 | * Exports the object as an array. |
||
| 1061 | * |
||
| 1062 | * You can specify the key type of the array by passing one of the class |
||
| 1063 | * type constants. |
||
| 1064 | * |
||
| 1065 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1066 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1067 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1068 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
| 1069 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
| 1070 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
| 1071 | * |
||
| 1072 | * @return array an associative array containing the field names (as keys) and field values |
||
| 1073 | */ |
||
| 1074 | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
||
| 1121 | |||
| 1122 | /** |
||
| 1123 | * Sets a field from the object by name passed in as a string. |
||
| 1124 | * |
||
| 1125 | * @param string $name |
||
| 1126 | * @param mixed $value field value |
||
| 1127 | * @param string $type The type of fieldname the $name is of: |
||
| 1128 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1129 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1130 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1131 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player |
||
| 1132 | */ |
||
| 1133 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
| 1139 | |||
| 1140 | /** |
||
| 1141 | * Sets a field from the object by Position as specified in the xml schema. |
||
| 1142 | * Zero-based. |
||
| 1143 | * |
||
| 1144 | * @param int $pos position in xml schema |
||
| 1145 | * @param mixed $value field value |
||
| 1146 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player |
||
| 1147 | */ |
||
| 1148 | public function setByPosition($pos, $value) |
||
| 1179 | |||
| 1180 | /** |
||
| 1181 | * Populates the object using an array. |
||
| 1182 | * |
||
| 1183 | * This is particularly useful when populating an object from one of the |
||
| 1184 | * request arrays (e.g. $_POST). This method goes through the column |
||
| 1185 | * names, checking to see whether a matching key exists in populated |
||
| 1186 | * array. If so the setByName() method is called for that column. |
||
| 1187 | * |
||
| 1188 | * You can specify the key type of the array by additionally passing one |
||
| 1189 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1190 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1191 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1192 | * |
||
| 1193 | * @param array $arr An array to populate the object from. |
||
| 1194 | * @param string $keyType The type of keys the array uses. |
||
| 1195 | * @return void |
||
| 1196 | */ |
||
| 1197 | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
||
| 1226 | |||
| 1227 | /** |
||
| 1228 | * Populate the current object from a string, using a given parser format |
||
| 1229 | * <code> |
||
| 1230 | * $book = new Book(); |
||
| 1231 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 1232 | * </code> |
||
| 1233 | * |
||
| 1234 | * You can specify the key type of the array by additionally passing one |
||
| 1235 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1236 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1237 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1238 | * |
||
| 1239 | * @param mixed $parser A AbstractParser instance, |
||
| 1240 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 1241 | * @param string $data The source data to import from |
||
| 1242 | * @param string $keyType The type of keys the array uses. |
||
| 1243 | * |
||
| 1244 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object, for fluid interface |
||
| 1245 | */ |
||
| 1246 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1256 | |||
| 1257 | /** |
||
| 1258 | * Build a Criteria object containing the values of all modified columns in this object. |
||
| 1259 | * |
||
| 1260 | * @return Criteria The Criteria object containing all modified values. |
||
| 1261 | */ |
||
| 1262 | public function buildCriteria() |
||
| 1293 | |||
| 1294 | /** |
||
| 1295 | * Builds a Criteria object containing the primary key for this object. |
||
| 1296 | * |
||
| 1297 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
| 1298 | * of whether or not they have been modified. |
||
| 1299 | * |
||
| 1300 | * @throws LogicException if no primary key is defined |
||
| 1301 | * |
||
| 1302 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
| 1303 | */ |
||
| 1304 | public function buildPkeyCriteria() |
||
| 1311 | |||
| 1312 | /** |
||
| 1313 | * If the primary key is not null, return the hashcode of the |
||
| 1314 | * primary key. Otherwise, return the hash code of the object. |
||
| 1315 | * |
||
| 1316 | * @return int Hashcode |
||
| 1317 | */ |
||
| 1318 | View Code Duplication | public function hashCode() |
|
| 1333 | |||
| 1334 | /** |
||
| 1335 | * Returns the primary key for this object (row). |
||
| 1336 | * @return int |
||
| 1337 | */ |
||
| 1338 | public function getPrimaryKey() |
||
| 1342 | |||
| 1343 | /** |
||
| 1344 | * Generic method to set the primary key (id column). |
||
| 1345 | * |
||
| 1346 | * @param int $key Primary key. |
||
| 1347 | * @return void |
||
| 1348 | */ |
||
| 1349 | public function setPrimaryKey($key) |
||
| 1353 | |||
| 1354 | /** |
||
| 1355 | * Returns true if the primary key for this object is null. |
||
| 1356 | * @return boolean |
||
| 1357 | */ |
||
| 1358 | public function isPrimaryKeyNull() |
||
| 1362 | |||
| 1363 | /** |
||
| 1364 | * Sets contents of passed object to values from current object. |
||
| 1365 | * |
||
| 1366 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1367 | * objects. |
||
| 1368 | * |
||
| 1369 | * @param object $copyObj An object of \eXpansion\Framework\PlayersBundle\Model\Player (or compatible) type. |
||
| 1370 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1371 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
| 1372 | * @throws PropelException |
||
| 1373 | */ |
||
| 1374 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
| 1402 | |||
| 1403 | /** |
||
| 1404 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
| 1405 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
| 1406 | * keys that are defined for the table. |
||
| 1407 | * |
||
| 1408 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1409 | * objects. |
||
| 1410 | * |
||
| 1411 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1412 | * @return \eXpansion\Framework\PlayersBundle\Model\Player Clone of current object. |
||
| 1413 | * @throws PropelException |
||
| 1414 | */ |
||
| 1415 | View Code Duplication | public function copy($deepCopy = false) |
|
| 1424 | |||
| 1425 | |||
| 1426 | /** |
||
| 1427 | * Initializes a collection based on the name of a relation. |
||
| 1428 | * Avoids crafting an 'init[$relationName]s' method name |
||
| 1429 | * that wouldn't work when StandardEnglishPluralizer is used. |
||
| 1430 | * |
||
| 1431 | * @param string $relationName The name of the relation to initialize |
||
| 1432 | * @return void |
||
| 1433 | */ |
||
| 1434 | public function initRelation($relationName) |
||
| 1440 | |||
| 1441 | /** |
||
| 1442 | * Clears out the collRecords collection |
||
| 1443 | * |
||
| 1444 | * This does not modify the database; however, it will remove any associated objects, causing |
||
| 1445 | * them to be refetched by subsequent calls to accessor method. |
||
| 1446 | * |
||
| 1447 | * @return void |
||
| 1448 | * @see addRecords() |
||
| 1449 | */ |
||
| 1450 | public function clearRecords() |
||
| 1454 | |||
| 1455 | /** |
||
| 1456 | * Reset is the collRecords collection loaded partially. |
||
| 1457 | */ |
||
| 1458 | public function resetPartialRecords($v = true) |
||
| 1462 | |||
| 1463 | /** |
||
| 1464 | * Initializes the collRecords collection. |
||
| 1465 | * |
||
| 1466 | * By default this just sets the collRecords collection to an empty array (like clearcollRecords()); |
||
| 1467 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
| 1468 | * to your application -- for example, setting the initial array to the values stored in database. |
||
| 1469 | * |
||
| 1470 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
| 1471 | * the collection even if it is not empty |
||
| 1472 | * |
||
| 1473 | * @return void |
||
| 1474 | */ |
||
| 1475 | public function initRecords($overrideExisting = true) |
||
| 1486 | |||
| 1487 | /** |
||
| 1488 | * Gets an array of Record objects which contain a foreign key that references this object. |
||
| 1489 | * |
||
| 1490 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
| 1491 | * Otherwise the results are fetched from the database the first time, then cached. |
||
| 1492 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
| 1493 | * If this ChildPlayer is new, it will return |
||
| 1494 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
| 1495 | * |
||
| 1496 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1497 | * @param ConnectionInterface $con optional connection object |
||
| 1498 | * @return ObjectCollection|Record[] List of Record objects |
||
| 1499 | * @throws PropelException |
||
| 1500 | */ |
||
| 1501 | public function getRecords(Criteria $criteria = null, ConnectionInterface $con = null) |
||
| 1544 | |||
| 1545 | /** |
||
| 1546 | * Sets a collection of Record objects related by a one-to-many relationship |
||
| 1547 | * to the current object. |
||
| 1548 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
| 1549 | * and new objects from the given Propel collection. |
||
| 1550 | * |
||
| 1551 | * @param Collection $records A Propel collection. |
||
| 1552 | * @param ConnectionInterface $con Optional connection object |
||
| 1553 | * @return $this|ChildPlayer The current object (for fluent API support) |
||
| 1554 | */ |
||
| 1555 | public function setRecords(Collection $records, ConnectionInterface $con = null) |
||
| 1577 | |||
| 1578 | /** |
||
| 1579 | * Returns the number of related BaseRecord objects. |
||
| 1580 | * |
||
| 1581 | * @param Criteria $criteria |
||
| 1582 | * @param boolean $distinct |
||
| 1583 | * @param ConnectionInterface $con |
||
| 1584 | * @return int Count of related BaseRecord objects. |
||
| 1585 | * @throws PropelException |
||
| 1586 | */ |
||
| 1587 | public function countRecords(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
||
| 1611 | |||
| 1612 | /** |
||
| 1613 | * Method called to associate a Record object to this object |
||
| 1614 | * through the Record foreign key attribute. |
||
| 1615 | * |
||
| 1616 | * @param Record $l Record |
||
| 1617 | * @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object (for fluent API support) |
||
| 1618 | */ |
||
| 1619 | public function addRecord(Record $l) |
||
| 1636 | |||
| 1637 | /** |
||
| 1638 | * @param Record $record The Record object to add. |
||
| 1639 | */ |
||
| 1640 | protected function doAddRecord(Record $record) |
||
| 1645 | |||
| 1646 | /** |
||
| 1647 | * @param Record $record The Record object to remove. |
||
| 1648 | * @return $this|ChildPlayer The current object (for fluent API support) |
||
| 1649 | */ |
||
| 1650 | public function removeRecord(Record $record) |
||
| 1665 | |||
| 1666 | /** |
||
| 1667 | * Clears the current object, sets all attributes to their default values and removes |
||
| 1668 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
| 1669 | * change of those foreign objects when you call `save` there). |
||
| 1670 | */ |
||
| 1671 | public function clear() |
||
| 1687 | |||
| 1688 | /** |
||
| 1689 | * Resets all references and back-references to other model objects or collections of model objects. |
||
| 1690 | * |
||
| 1691 | * This method is used to reset all php object references (not the actual reference in the database). |
||
| 1692 | * Necessary for object serialisation. |
||
| 1693 | * |
||
| 1694 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
| 1695 | */ |
||
| 1696 | public function clearAllReferences($deep = false) |
||
| 1708 | |||
| 1709 | /** |
||
| 1710 | * Return the string representation of this object |
||
| 1711 | * |
||
| 1712 | * @return string The value of the 'login' column |
||
| 1713 | */ |
||
| 1714 | public function __toString() |
||
| 1718 | |||
| 1719 | /** |
||
| 1720 | * Code to be run before persisting the object |
||
| 1721 | * @param ConnectionInterface $con |
||
| 1722 | * @return boolean |
||
| 1723 | */ |
||
| 1724 | public function preSave(ConnectionInterface $con = null) |
||
| 1731 | |||
| 1732 | /** |
||
| 1733 | * Code to be run after persisting the object |
||
| 1734 | * @param ConnectionInterface $con |
||
| 1735 | */ |
||
| 1736 | public function postSave(ConnectionInterface $con = null) |
||
| 1742 | |||
| 1743 | /** |
||
| 1744 | * Code to be run before inserting to database |
||
| 1745 | * @param ConnectionInterface $con |
||
| 1746 | * @return boolean |
||
| 1747 | */ |
||
| 1748 | public function preInsert(ConnectionInterface $con = null) |
||
| 1755 | |||
| 1756 | /** |
||
| 1757 | * Code to be run after inserting to database |
||
| 1758 | * @param ConnectionInterface $con |
||
| 1759 | */ |
||
| 1760 | public function postInsert(ConnectionInterface $con = null) |
||
| 1766 | |||
| 1767 | /** |
||
| 1768 | * Code to be run before updating the object in database |
||
| 1769 | * @param ConnectionInterface $con |
||
| 1770 | * @return boolean |
||
| 1771 | */ |
||
| 1772 | public function preUpdate(ConnectionInterface $con = null) |
||
| 1779 | |||
| 1780 | /** |
||
| 1781 | * Code to be run after updating the object in database |
||
| 1782 | * @param ConnectionInterface $con |
||
| 1783 | */ |
||
| 1784 | public function postUpdate(ConnectionInterface $con = null) |
||
| 1790 | |||
| 1791 | /** |
||
| 1792 | * Code to be run before deleting the object in database |
||
| 1793 | * @param ConnectionInterface $con |
||
| 1794 | * @return boolean |
||
| 1795 | */ |
||
| 1796 | public function preDelete(ConnectionInterface $con = null) |
||
| 1803 | |||
| 1804 | /** |
||
| 1805 | * Code to be run after deleting the object in database |
||
| 1806 | * @param ConnectionInterface $con |
||
| 1807 | */ |
||
| 1808 | public function postDelete(ConnectionInterface $con = null) |
||
| 1814 | |||
| 1815 | |||
| 1816 | /** |
||
| 1817 | * Derived method to catches calls to undefined methods. |
||
| 1818 | * |
||
| 1819 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
| 1820 | * Allows to define default __call() behavior if you overwrite __call() |
||
| 1821 | * |
||
| 1822 | * @param string $name |
||
| 1823 | * @param mixed $params |
||
| 1824 | * |
||
| 1825 | * @return array|string |
||
| 1826 | */ |
||
| 1827 | View Code Duplication | public function __call($name, $params) |
|
| 1856 | |||
| 1857 | } |
||
| 1858 |
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.