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 Task 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 Task, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 30 | abstract class Task implements ActiveRecordInterface |
||
| 31 | { |
||
| 32 | /** |
||
| 33 | * TableMap class name |
||
| 34 | */ |
||
| 35 | const TABLE_MAP = '\\Core\\Models\\Task\\Map\\TaskTableMap'; |
||
| 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 created_at field. |
||
| 72 | * @var \DateTime |
||
| 73 | */ |
||
| 74 | protected $created_at; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * The value for the updated_at field. |
||
| 78 | * @var \DateTime |
||
| 79 | */ |
||
| 80 | protected $updated_at; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Flag to prevent endless save loop, if this object is referenced |
||
| 84 | * by another object which falls in this transaction. |
||
| 85 | * |
||
| 86 | * @var boolean |
||
| 87 | */ |
||
| 88 | protected $alreadyInSave = false; |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Initializes internal state of Core\Models\Task\Base\Task object. |
||
| 92 | */ |
||
| 93 | public function __construct() |
||
| 96 | |||
| 97 | /** |
||
| 98 | * Returns whether the object has been modified. |
||
| 99 | * |
||
| 100 | * @return boolean True if the object has been modified. |
||
| 101 | */ |
||
| 102 | public function isModified() |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Has specified column been modified? |
||
| 109 | * |
||
| 110 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
| 111 | * @return boolean True if $col has been modified. |
||
| 112 | */ |
||
| 113 | public function isColumnModified($col) |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Get the columns that have been modified in this object. |
||
| 120 | * @return array A unique list of the modified column names for this object. |
||
| 121 | */ |
||
| 122 | public function getModifiedColumns() |
||
| 126 | |||
| 127 | /** |
||
| 128 | * Returns whether the object has ever been saved. This will |
||
| 129 | * be false, if the object was retrieved from storage or was created |
||
| 130 | * and then saved. |
||
| 131 | * |
||
| 132 | * @return boolean true, if the object has never been persisted. |
||
| 133 | */ |
||
| 134 | public function isNew() |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Setter for the isNew attribute. This method will be called |
||
| 141 | * by Propel-generated children and objects. |
||
| 142 | * |
||
| 143 | * @param boolean $b the state of the object. |
||
| 144 | */ |
||
| 145 | public function setNew($b) |
||
| 149 | |||
| 150 | /** |
||
| 151 | * Whether this object has been deleted. |
||
| 152 | * @return boolean The deleted state of this object. |
||
| 153 | */ |
||
| 154 | public function isDeleted() |
||
| 158 | |||
| 159 | /** |
||
| 160 | * Specify whether this object has been deleted. |
||
| 161 | * @param boolean $b The deleted state of this object. |
||
| 162 | * @return void |
||
| 163 | */ |
||
| 164 | public function setDeleted($b) |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Sets the modified state for the object to be false. |
||
| 171 | * @param string $col If supplied, only the specified column is reset. |
||
| 172 | * @return void |
||
| 173 | */ |
||
| 174 | View Code Duplication | public function resetModified($col = null) |
|
| 184 | |||
| 185 | /** |
||
| 186 | * Compares this with another <code>Task</code> instance. If |
||
| 187 | * <code>obj</code> is an instance of <code>Task</code>, delegates to |
||
| 188 | * <code>equals(Task)</code>. Otherwise, returns <code>false</code>. |
||
| 189 | * |
||
| 190 | * @param mixed $obj The object to compare to. |
||
| 191 | * @return boolean Whether equal to the object specified. |
||
| 192 | */ |
||
| 193 | View Code Duplication | public function equals($obj) |
|
| 209 | |||
| 210 | /** |
||
| 211 | * Get the associative array of the virtual columns in this object |
||
| 212 | * |
||
| 213 | * @return array |
||
| 214 | */ |
||
| 215 | public function getVirtualColumns() |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Checks the existence of a virtual column in this object |
||
| 222 | * |
||
| 223 | * @param string $name The virtual column name |
||
| 224 | * @return boolean |
||
| 225 | */ |
||
| 226 | public function hasVirtualColumn($name) |
||
| 230 | |||
| 231 | /** |
||
| 232 | * Get the value of a virtual column in this object |
||
| 233 | * |
||
| 234 | * @param string $name The virtual column name |
||
| 235 | * @return mixed |
||
| 236 | * |
||
| 237 | * @throws PropelException |
||
| 238 | */ |
||
| 239 | View Code Duplication | public function getVirtualColumn($name) |
|
| 247 | |||
| 248 | /** |
||
| 249 | * Set the value of a virtual column in this object |
||
| 250 | * |
||
| 251 | * @param string $name The virtual column name |
||
| 252 | * @param mixed $value The value to give to the virtual column |
||
| 253 | * |
||
| 254 | * @return $this|Task The current object, for fluid interface |
||
| 255 | */ |
||
| 256 | public function setVirtualColumn($name, $value) |
||
| 262 | |||
| 263 | /** |
||
| 264 | * Logs a message using Propel::log(). |
||
| 265 | * |
||
| 266 | * @param string $msg |
||
| 267 | * @param int $priority One of the Propel::LOG_* logging levels |
||
| 268 | * @return boolean |
||
| 269 | */ |
||
| 270 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
| 274 | |||
| 275 | /** |
||
| 276 | * Export the current object properties to a string, using a given parser format |
||
| 277 | * <code> |
||
| 278 | * $book = BookQuery::create()->findPk(9012); |
||
| 279 | * echo $book->exportTo('JSON'); |
||
| 280 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 281 | * </code> |
||
| 282 | * |
||
| 283 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 284 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
| 285 | * @return string The exported data |
||
| 286 | */ |
||
| 287 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 295 | |||
| 296 | /** |
||
| 297 | * Clean up internal collections prior to serializing |
||
| 298 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
| 299 | */ |
||
| 300 | public function __sleep() |
||
| 306 | |||
| 307 | /** |
||
| 308 | * Get the [id] column value. |
||
| 309 | * |
||
| 310 | * @return int |
||
| 311 | */ |
||
| 312 | public function getId() |
||
| 316 | |||
| 317 | /** |
||
| 318 | * Get the [optionally formatted] temporal [created_at] column value. |
||
| 319 | * |
||
| 320 | * |
||
| 321 | * @param string $format The date/time format string (either date()-style or strftime()-style). |
||
| 322 | * If format is NULL, then the raw DateTime object will be returned. |
||
| 323 | * |
||
| 324 | * @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 |
||
| 325 | * |
||
| 326 | * @throws PropelException - if unable to parse/validate the date/time value. |
||
| 327 | */ |
||
| 328 | View Code Duplication | public function getCreatedAt($format = NULL) |
|
| 336 | |||
| 337 | /** |
||
| 338 | * Get the [optionally formatted] temporal [updated_at] column value. |
||
| 339 | * |
||
| 340 | * |
||
| 341 | * @param string $format The date/time format string (either date()-style or strftime()-style). |
||
| 342 | * If format is NULL, then the raw DateTime object will be returned. |
||
| 343 | * |
||
| 344 | * @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 |
||
| 345 | * |
||
| 346 | * @throws PropelException - if unable to parse/validate the date/time value. |
||
| 347 | */ |
||
| 348 | View Code Duplication | public function getUpdatedAt($format = NULL) |
|
| 356 | |||
| 357 | /** |
||
| 358 | * Set the value of [id] column. |
||
| 359 | * |
||
| 360 | * @param int $v new value |
||
| 361 | * @return $this|\Core\Models\Task\Task The current object (for fluent API support) |
||
| 362 | */ |
||
| 363 | public function setId($v) |
||
| 376 | |||
| 377 | /** |
||
| 378 | * Sets the value of [created_at] column to a normalized version of the date/time value specified. |
||
| 379 | * |
||
| 380 | * @param mixed $v string, integer (timestamp), or \DateTime value. |
||
| 381 | * Empty strings are treated as NULL. |
||
| 382 | * @return $this|\Core\Models\Task\Task The current object (for fluent API support) |
||
| 383 | */ |
||
| 384 | View Code Duplication | public function setCreatedAt($v) |
|
| 396 | |||
| 397 | /** |
||
| 398 | * Sets the value of [updated_at] column to a normalized version of the date/time value specified. |
||
| 399 | * |
||
| 400 | * @param mixed $v string, integer (timestamp), or \DateTime value. |
||
| 401 | * Empty strings are treated as NULL. |
||
| 402 | * @return $this|\Core\Models\Task\Task The current object (for fluent API support) |
||
| 403 | */ |
||
| 404 | View Code Duplication | public function setUpdatedAt($v) |
|
| 416 | |||
| 417 | /** |
||
| 418 | * Indicates whether the columns in this object are only set to default values. |
||
| 419 | * |
||
| 420 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
| 421 | * modified _and_ has some values set which are non-default. |
||
| 422 | * |
||
| 423 | * @return boolean Whether the columns in this object are only been set with default values. |
||
| 424 | */ |
||
| 425 | public function hasOnlyDefaultValues() |
||
| 430 | |||
| 431 | /** |
||
| 432 | * Hydrates (populates) the object variables with values from the database resultset. |
||
| 433 | * |
||
| 434 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
| 435 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
| 436 | * for results of JOIN queries where the resultset row includes columns from two or |
||
| 437 | * more tables. |
||
| 438 | * |
||
| 439 | * @param array $row The row returned by DataFetcher->fetch(). |
||
| 440 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
| 441 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
| 442 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
| 443 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 444 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 445 | * |
||
| 446 | * @return int next starting column |
||
| 447 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
| 448 | */ |
||
| 449 | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
||
| 481 | |||
| 482 | /** |
||
| 483 | * Checks and repairs the internal consistency of the object. |
||
| 484 | * |
||
| 485 | * This method is executed after an already-instantiated object is re-hydrated |
||
| 486 | * from the database. It exists to check any foreign keys to make sure that |
||
| 487 | * the objects related to the current object are correct based on foreign key. |
||
| 488 | * |
||
| 489 | * You can override this method in the stub class, but you should always invoke |
||
| 490 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
| 491 | * in case your model changes. |
||
| 492 | * |
||
| 493 | * @throws PropelException |
||
| 494 | */ |
||
| 495 | public function ensureConsistency() |
||
| 498 | |||
| 499 | /** |
||
| 500 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
| 501 | * |
||
| 502 | * This will only work if the object has been saved and has a valid primary key set. |
||
| 503 | * |
||
| 504 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
| 505 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
| 506 | * @return void |
||
| 507 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
| 508 | */ |
||
| 509 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
| 538 | |||
| 539 | /** |
||
| 540 | * Removes this object from datastore and sets delete attribute. |
||
| 541 | * |
||
| 542 | * @param ConnectionInterface $con |
||
| 543 | * @return void |
||
| 544 | * @throws PropelException |
||
| 545 | * @see Task::setDeleted() |
||
| 546 | * @see Task::isDeleted() |
||
| 547 | */ |
||
| 548 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 569 | |||
| 570 | /** |
||
| 571 | * Persists this object to the database. |
||
| 572 | * |
||
| 573 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 574 | * All modified related objects will also be persisted in the doSave() |
||
| 575 | * method. This method wraps all precipitate database operations in a |
||
| 576 | * single transaction. |
||
| 577 | * |
||
| 578 | * @param ConnectionInterface $con |
||
| 579 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 580 | * @throws PropelException |
||
| 581 | * @see doSave() |
||
| 582 | */ |
||
| 583 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
| 617 | |||
| 618 | /** |
||
| 619 | * Performs the work of inserting or updating the row in the database. |
||
| 620 | * |
||
| 621 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 622 | * All related objects are also updated in this method. |
||
| 623 | * |
||
| 624 | * @param ConnectionInterface $con |
||
| 625 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 626 | * @throws PropelException |
||
| 627 | * @see save() |
||
| 628 | */ |
||
| 629 | View Code Duplication | protected function doSave(ConnectionInterface $con) |
|
| 652 | |||
| 653 | /** |
||
| 654 | * Insert the row in the database. |
||
| 655 | * |
||
| 656 | * @param ConnectionInterface $con |
||
| 657 | * |
||
| 658 | * @throws PropelException |
||
| 659 | * @see doSave() |
||
| 660 | */ |
||
| 661 | protected function doInsert(ConnectionInterface $con) |
||
| 718 | |||
| 719 | /** |
||
| 720 | * Update the row in the database. |
||
| 721 | * |
||
| 722 | * @param ConnectionInterface $con |
||
| 723 | * |
||
| 724 | * @return Integer Number of updated rows |
||
| 725 | * @see doSave() |
||
| 726 | */ |
||
| 727 | protected function doUpdate(ConnectionInterface $con) |
||
| 734 | |||
| 735 | /** |
||
| 736 | * Retrieves a field from the object by name passed in as a string. |
||
| 737 | * |
||
| 738 | * @param string $name name |
||
| 739 | * @param string $type The type of fieldname the $name is of: |
||
| 740 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 741 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 742 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 743 | * @return mixed Value of field. |
||
| 744 | */ |
||
| 745 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 752 | |||
| 753 | /** |
||
| 754 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
| 755 | * Zero-based. |
||
| 756 | * |
||
| 757 | * @param int $pos position in xml schema |
||
| 758 | * @return mixed Value of field at $pos |
||
| 759 | */ |
||
| 760 | public function getByPosition($pos) |
||
| 777 | |||
| 778 | /** |
||
| 779 | * Exports the object as an array. |
||
| 780 | * |
||
| 781 | * You can specify the key type of the array by passing one of the class |
||
| 782 | * type constants. |
||
| 783 | * |
||
| 784 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 785 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 786 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 787 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
| 788 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
| 789 | * |
||
| 790 | * @return array an associative array containing the field names (as keys) and field values |
||
| 791 | */ |
||
| 792 | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) |
||
| 827 | |||
| 828 | /** |
||
| 829 | * Sets a field from the object by name passed in as a string. |
||
| 830 | * |
||
| 831 | * @param string $name |
||
| 832 | * @param mixed $value field value |
||
| 833 | * @param string $type The type of fieldname the $name is of: |
||
| 834 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 835 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 836 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 837 | * @return $this|\Core\Models\Task\Task |
||
| 838 | */ |
||
| 839 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
| 845 | |||
| 846 | /** |
||
| 847 | * Sets a field from the object by Position as specified in the xml schema. |
||
| 848 | * Zero-based. |
||
| 849 | * |
||
| 850 | * @param int $pos position in xml schema |
||
| 851 | * @param mixed $value field value |
||
| 852 | * @return $this|\Core\Models\Task\Task |
||
| 853 | */ |
||
| 854 | public function setByPosition($pos, $value) |
||
| 870 | |||
| 871 | /** |
||
| 872 | * Populates the object using an array. |
||
| 873 | * |
||
| 874 | * This is particularly useful when populating an object from one of the |
||
| 875 | * request arrays (e.g. $_POST). This method goes through the column |
||
| 876 | * names, checking to see whether a matching key exists in populated |
||
| 877 | * array. If so the setByName() method is called for that column. |
||
| 878 | * |
||
| 879 | * You can specify the key type of the array by additionally passing one |
||
| 880 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 881 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 882 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 883 | * |
||
| 884 | * @param array $arr An array to populate the object from. |
||
| 885 | * @param string $keyType The type of keys the array uses. |
||
| 886 | * @return void |
||
| 887 | */ |
||
| 888 | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
||
| 902 | |||
| 903 | /** |
||
| 904 | * Populate the current object from a string, using a given parser format |
||
| 905 | * <code> |
||
| 906 | * $book = new Book(); |
||
| 907 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 908 | * </code> |
||
| 909 | * |
||
| 910 | * You can specify the key type of the array by additionally passing one |
||
| 911 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 912 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 913 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 914 | * |
||
| 915 | * @param mixed $parser A AbstractParser instance, |
||
| 916 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 917 | * @param string $data The source data to import from |
||
| 918 | * @param string $keyType The type of keys the array uses. |
||
| 919 | * |
||
| 920 | * @return $this|\Core\Models\Task\Task The current object, for fluid interface |
||
| 921 | */ |
||
| 922 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 932 | |||
| 933 | /** |
||
| 934 | * Build a Criteria object containing the values of all modified columns in this object. |
||
| 935 | * |
||
| 936 | * @return Criteria The Criteria object containing all modified values. |
||
| 937 | */ |
||
| 938 | public function buildCriteria() |
||
| 954 | |||
| 955 | /** |
||
| 956 | * Builds a Criteria object containing the primary key for this object. |
||
| 957 | * |
||
| 958 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
| 959 | * of whether or not they have been modified. |
||
| 960 | * |
||
| 961 | * @throws LogicException if no primary key is defined |
||
| 962 | * |
||
| 963 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
| 964 | */ |
||
| 965 | public function buildPkeyCriteria() |
||
| 972 | |||
| 973 | /** |
||
| 974 | * If the primary key is not null, return the hashcode of the |
||
| 975 | * primary key. Otherwise, return the hash code of the object. |
||
| 976 | * |
||
| 977 | * @return int Hashcode |
||
| 978 | */ |
||
| 979 | View Code Duplication | public function hashCode() |
|
| 994 | |||
| 995 | /** |
||
| 996 | * Returns the primary key for this object (row). |
||
| 997 | * @return int |
||
| 998 | */ |
||
| 999 | public function getPrimaryKey() |
||
| 1003 | |||
| 1004 | /** |
||
| 1005 | * Generic method to set the primary key (id column). |
||
| 1006 | * |
||
| 1007 | * @param int $key Primary key. |
||
| 1008 | * @return void |
||
| 1009 | */ |
||
| 1010 | public function setPrimaryKey($key) |
||
| 1014 | |||
| 1015 | /** |
||
| 1016 | * Returns true if the primary key for this object is null. |
||
| 1017 | * @return boolean |
||
| 1018 | */ |
||
| 1019 | public function isPrimaryKeyNull() |
||
| 1023 | |||
| 1024 | /** |
||
| 1025 | * Sets contents of passed object to values from current object. |
||
| 1026 | * |
||
| 1027 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1028 | * objects. |
||
| 1029 | * |
||
| 1030 | * @param object $copyObj An object of \Core\Models\Task\Task (or compatible) type. |
||
| 1031 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1032 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
| 1033 | * @throws PropelException |
||
| 1034 | */ |
||
| 1035 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
| 1044 | |||
| 1045 | /** |
||
| 1046 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
| 1047 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
| 1048 | * keys that are defined for the table. |
||
| 1049 | * |
||
| 1050 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1051 | * objects. |
||
| 1052 | * |
||
| 1053 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1054 | * @return \Core\Models\Task\Task Clone of current object. |
||
| 1055 | * @throws PropelException |
||
| 1056 | */ |
||
| 1057 | View Code Duplication | public function copy($deepCopy = false) |
|
| 1066 | |||
| 1067 | /** |
||
| 1068 | * Clears the current object, sets all attributes to their default values and removes |
||
| 1069 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
| 1070 | * change of those foreign objects when you call `save` there). |
||
| 1071 | */ |
||
| 1072 | View Code Duplication | public function clear() |
|
| 1083 | |||
| 1084 | /** |
||
| 1085 | * Resets all references and back-references to other model objects or collections of model objects. |
||
| 1086 | * |
||
| 1087 | * This method is used to reset all php object references (not the actual reference in the database). |
||
| 1088 | * Necessary for object serialisation. |
||
| 1089 | * |
||
| 1090 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
| 1091 | */ |
||
| 1092 | public function clearAllReferences($deep = false) |
||
| 1098 | |||
| 1099 | /** |
||
| 1100 | * Return the string representation of this object |
||
| 1101 | * |
||
| 1102 | * @return string |
||
| 1103 | */ |
||
| 1104 | public function __toString() |
||
| 1108 | |||
| 1109 | /** |
||
| 1110 | * Code to be run before persisting the object |
||
| 1111 | * @param ConnectionInterface $con |
||
| 1112 | * @return boolean |
||
| 1113 | */ |
||
| 1114 | public function preSave(ConnectionInterface $con = null) |
||
| 1118 | |||
| 1119 | /** |
||
| 1120 | * Code to be run after persisting the object |
||
| 1121 | * @param ConnectionInterface $con |
||
| 1122 | */ |
||
| 1123 | public function postSave(ConnectionInterface $con = null) |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Code to be run before inserting to database |
||
| 1130 | * @param ConnectionInterface $con |
||
| 1131 | * @return boolean |
||
| 1132 | */ |
||
| 1133 | public function preInsert(ConnectionInterface $con = null) |
||
| 1137 | |||
| 1138 | /** |
||
| 1139 | * Code to be run after inserting to database |
||
| 1140 | * @param ConnectionInterface $con |
||
| 1141 | */ |
||
| 1142 | public function postInsert(ConnectionInterface $con = null) |
||
| 1146 | |||
| 1147 | /** |
||
| 1148 | * Code to be run before updating the object in database |
||
| 1149 | * @param ConnectionInterface $con |
||
| 1150 | * @return boolean |
||
| 1151 | */ |
||
| 1152 | public function preUpdate(ConnectionInterface $con = null) |
||
| 1156 | |||
| 1157 | /** |
||
| 1158 | * Code to be run after updating the object in database |
||
| 1159 | * @param ConnectionInterface $con |
||
| 1160 | */ |
||
| 1161 | public function postUpdate(ConnectionInterface $con = null) |
||
| 1165 | |||
| 1166 | /** |
||
| 1167 | * Code to be run before deleting the object in database |
||
| 1168 | * @param ConnectionInterface $con |
||
| 1169 | * @return boolean |
||
| 1170 | */ |
||
| 1171 | public function preDelete(ConnectionInterface $con = null) |
||
| 1175 | |||
| 1176 | /** |
||
| 1177 | * Code to be run after deleting the object in database |
||
| 1178 | * @param ConnectionInterface $con |
||
| 1179 | */ |
||
| 1180 | public function postDelete(ConnectionInterface $con = null) |
||
| 1184 | |||
| 1185 | |||
| 1186 | /** |
||
| 1187 | * Derived method to catches calls to undefined methods. |
||
| 1188 | * |
||
| 1189 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
| 1190 | * Allows to define default __call() behavior if you overwrite __call() |
||
| 1191 | * |
||
| 1192 | * @param string $name |
||
| 1193 | * @param mixed $params |
||
| 1194 | * |
||
| 1195 | * @return array|string |
||
| 1196 | */ |
||
| 1197 | View Code Duplication | public function __call($name, $params) |
|
| 1226 | |||
| 1227 | } |
||
| 1228 |
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.