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 Subscription 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 Subscription, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 36 | abstract class Subscription implements ActiveRecordInterface |
||
| 37 | { |
||
| 38 | /** |
||
| 39 | * TableMap class name |
||
| 40 | */ |
||
| 41 | const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\SubscriptionTableMap'; |
||
| 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 instance_name field. |
||
| 79 | * |
||
| 80 | * @var string |
||
| 81 | */ |
||
| 82 | protected $instance_name; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * The value for the user_id field. |
||
| 86 | * |
||
| 87 | * @var int |
||
| 88 | */ |
||
| 89 | protected $user_id; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * The value for the channel_id field. |
||
| 93 | * |
||
| 94 | * @var int |
||
| 95 | */ |
||
| 96 | protected $channel_id; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * The value for the subscription_id field. |
||
| 100 | * |
||
| 101 | * @var int |
||
| 102 | */ |
||
| 103 | protected $subscription_id; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * The value for the started field. |
||
| 107 | * |
||
| 108 | * @var \DateTime |
||
| 109 | */ |
||
| 110 | protected $started; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * The value for the stopped field. |
||
| 114 | * |
||
| 115 | * @var \DateTime |
||
| 116 | */ |
||
| 117 | protected $stopped; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * The value for the title field. |
||
| 121 | * |
||
| 122 | * @var string |
||
| 123 | */ |
||
| 124 | protected $title; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * The value for the service field. |
||
| 128 | * |
||
| 129 | * @var string |
||
| 130 | */ |
||
| 131 | protected $service; |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @var ChildInstance |
||
| 135 | */ |
||
| 136 | protected $aInstance; |
||
| 137 | |||
| 138 | /** |
||
| 139 | * @var ChildUser |
||
| 140 | */ |
||
| 141 | protected $aUser; |
||
| 142 | |||
| 143 | /** |
||
| 144 | * @var ChildChannel |
||
| 145 | */ |
||
| 146 | protected $aChannel; |
||
| 147 | |||
| 148 | /** |
||
| 149 | * Flag to prevent endless save loop, if this object is referenced |
||
| 150 | * by another object which falls in this transaction. |
||
| 151 | * |
||
| 152 | * @var boolean |
||
| 153 | */ |
||
| 154 | protected $alreadyInSave = false; |
||
| 155 | |||
| 156 | /** |
||
| 157 | * Initializes internal state of Jalle19\StatusManager\Database\Base\Subscription object. |
||
| 158 | */ |
||
| 159 | public function __construct() |
||
| 162 | |||
| 163 | /** |
||
| 164 | * Returns whether the object has been modified. |
||
| 165 | * |
||
| 166 | * @return boolean True if the object has been modified. |
||
| 167 | */ |
||
| 168 | public function isModified() |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Has specified column been modified? |
||
| 175 | * |
||
| 176 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
| 177 | * @return boolean True if $col has been modified. |
||
| 178 | */ |
||
| 179 | public function isColumnModified($col) |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Get the columns that have been modified in this object. |
||
| 186 | * @return array A unique list of the modified column names for this object. |
||
| 187 | */ |
||
| 188 | public function getModifiedColumns() |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Returns whether the object has ever been saved. This will |
||
| 195 | * be false, if the object was retrieved from storage or was created |
||
| 196 | * and then saved. |
||
| 197 | * |
||
| 198 | * @return boolean true, if the object has never been persisted. |
||
| 199 | */ |
||
| 200 | public function isNew() |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Setter for the isNew attribute. This method will be called |
||
| 207 | * by Propel-generated children and objects. |
||
| 208 | * |
||
| 209 | * @param boolean $b the state of the object. |
||
| 210 | */ |
||
| 211 | public function setNew($b) |
||
| 215 | |||
| 216 | /** |
||
| 217 | * Whether this object has been deleted. |
||
| 218 | * @return boolean The deleted state of this object. |
||
| 219 | */ |
||
| 220 | public function isDeleted() |
||
| 224 | |||
| 225 | /** |
||
| 226 | * Specify whether this object has been deleted. |
||
| 227 | * @param boolean $b The deleted state of this object. |
||
| 228 | * @return void |
||
| 229 | */ |
||
| 230 | public function setDeleted($b) |
||
| 234 | |||
| 235 | /** |
||
| 236 | * Sets the modified state for the object to be false. |
||
| 237 | * @param string $col If supplied, only the specified column is reset. |
||
| 238 | * @return void |
||
| 239 | */ |
||
| 240 | View Code Duplication | public function resetModified($col = null) |
|
| 250 | |||
| 251 | /** |
||
| 252 | * Compares this with another <code>Subscription</code> instance. If |
||
| 253 | * <code>obj</code> is an instance of <code>Subscription</code>, delegates to |
||
| 254 | * <code>equals(Subscription)</code>. Otherwise, returns <code>false</code>. |
||
| 255 | * |
||
| 256 | * @param mixed $obj The object to compare to. |
||
| 257 | * @return boolean Whether equal to the object specified. |
||
| 258 | */ |
||
| 259 | View Code Duplication | public function equals($obj) |
|
| 275 | |||
| 276 | /** |
||
| 277 | * Get the associative array of the virtual columns in this object |
||
| 278 | * |
||
| 279 | * @return array |
||
| 280 | */ |
||
| 281 | public function getVirtualColumns() |
||
| 285 | |||
| 286 | /** |
||
| 287 | * Checks the existence of a virtual column in this object |
||
| 288 | * |
||
| 289 | * @param string $name The virtual column name |
||
| 290 | * @return boolean |
||
| 291 | */ |
||
| 292 | public function hasVirtualColumn($name) |
||
| 296 | |||
| 297 | /** |
||
| 298 | * Get the value of a virtual column in this object |
||
| 299 | * |
||
| 300 | * @param string $name The virtual column name |
||
| 301 | * @return mixed |
||
| 302 | * |
||
| 303 | * @throws PropelException |
||
| 304 | */ |
||
| 305 | View Code Duplication | public function getVirtualColumn($name) |
|
| 313 | |||
| 314 | /** |
||
| 315 | * Set the value of a virtual column in this object |
||
| 316 | * |
||
| 317 | * @param string $name The virtual column name |
||
| 318 | * @param mixed $value The value to give to the virtual column |
||
| 319 | * |
||
| 320 | * @return $this|Subscription The current object, for fluid interface |
||
| 321 | */ |
||
| 322 | public function setVirtualColumn($name, $value) |
||
| 328 | |||
| 329 | /** |
||
| 330 | * Logs a message using Propel::log(). |
||
| 331 | * |
||
| 332 | * @param string $msg |
||
| 333 | * @param int $priority One of the Propel::LOG_* logging levels |
||
| 334 | * @return boolean |
||
| 335 | */ |
||
| 336 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
| 340 | |||
| 341 | /** |
||
| 342 | * Export the current object properties to a string, using a given parser format |
||
| 343 | * <code> |
||
| 344 | * $book = BookQuery::create()->findPk(9012); |
||
| 345 | * echo $book->exportTo('JSON'); |
||
| 346 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 347 | * </code> |
||
| 348 | * |
||
| 349 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 350 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
| 351 | * @return string The exported data |
||
| 352 | */ |
||
| 353 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 361 | |||
| 362 | /** |
||
| 363 | * Clean up internal collections prior to serializing |
||
| 364 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
| 365 | */ |
||
| 366 | View Code Duplication | public function __sleep() |
|
| 380 | |||
| 381 | /** |
||
| 382 | * Get the [id] column value. |
||
| 383 | * |
||
| 384 | * @return int |
||
| 385 | */ |
||
| 386 | public function getId() |
||
| 390 | |||
| 391 | /** |
||
| 392 | * Get the [instance_name] column value. |
||
| 393 | * |
||
| 394 | * @return string |
||
| 395 | */ |
||
| 396 | public function getInstanceName() |
||
| 400 | |||
| 401 | /** |
||
| 402 | * Get the [user_id] column value. |
||
| 403 | * |
||
| 404 | * @return int |
||
| 405 | */ |
||
| 406 | public function getUserId() |
||
| 410 | |||
| 411 | /** |
||
| 412 | * Get the [channel_id] column value. |
||
| 413 | * |
||
| 414 | * @return int |
||
| 415 | */ |
||
| 416 | public function getChannelId() |
||
| 420 | |||
| 421 | /** |
||
| 422 | * Get the [subscription_id] column value. |
||
| 423 | * |
||
| 424 | * @return int |
||
| 425 | */ |
||
| 426 | public function getSubscriptionId() |
||
| 430 | |||
| 431 | /** |
||
| 432 | * Get the [optionally formatted] temporal [started] column value. |
||
| 433 | * |
||
| 434 | * |
||
| 435 | * @param string $format The date/time format string (either date()-style or strftime()-style). |
||
| 436 | * If format is NULL, then the raw DateTime object will be returned. |
||
| 437 | * |
||
| 438 | * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
||
| 439 | * |
||
| 440 | * @throws PropelException - if unable to parse/validate the date/time value. |
||
| 441 | */ |
||
| 442 | View Code Duplication | public function getStarted($format = NULL) |
|
| 450 | |||
| 451 | /** |
||
| 452 | * Get the [optionally formatted] temporal [stopped] column value. |
||
| 453 | * |
||
| 454 | * |
||
| 455 | * @param string $format The date/time format string (either date()-style or strftime()-style). |
||
| 456 | * If format is NULL, then the raw DateTime object will be returned. |
||
| 457 | * |
||
| 458 | * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
||
| 459 | * |
||
| 460 | * @throws PropelException - if unable to parse/validate the date/time value. |
||
| 461 | */ |
||
| 462 | public function getStopped($format = NULL) |
||
| 470 | |||
| 471 | /** |
||
| 472 | * Get the [title] column value. |
||
| 473 | * |
||
| 474 | * @return string |
||
| 475 | */ |
||
| 476 | public function getTitle() |
||
| 480 | |||
| 481 | /** |
||
| 482 | * Get the [service] column value. |
||
| 483 | * |
||
| 484 | * @return string |
||
| 485 | */ |
||
| 486 | public function getService() |
||
| 490 | |||
| 491 | /** |
||
| 492 | * Set the value of [id] column. |
||
| 493 | * |
||
| 494 | * @param int $v new value |
||
| 495 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 496 | */ |
||
| 497 | View Code Duplication | public function setId($v) |
|
| 510 | |||
| 511 | /** |
||
| 512 | * Set the value of [instance_name] column. |
||
| 513 | * |
||
| 514 | * @param string $v new value |
||
| 515 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 516 | */ |
||
| 517 | View Code Duplication | public function setInstanceName($v) |
|
| 534 | |||
| 535 | /** |
||
| 536 | * Set the value of [user_id] column. |
||
| 537 | * |
||
| 538 | * @param int $v new value |
||
| 539 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 540 | */ |
||
| 541 | View Code Duplication | public function setUserId($v) |
|
| 558 | |||
| 559 | /** |
||
| 560 | * Set the value of [channel_id] column. |
||
| 561 | * |
||
| 562 | * @param int $v new value |
||
| 563 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 564 | */ |
||
| 565 | View Code Duplication | public function setChannelId($v) |
|
| 582 | |||
| 583 | /** |
||
| 584 | * Set the value of [subscription_id] column. |
||
| 585 | * |
||
| 586 | * @param int $v new value |
||
| 587 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 588 | */ |
||
| 589 | View Code Duplication | public function setSubscriptionId($v) |
|
| 602 | |||
| 603 | /** |
||
| 604 | * Sets the value of [started] column to a normalized version of the date/time value specified. |
||
| 605 | * |
||
| 606 | * @param mixed $v string, integer (timestamp), or \DateTime value. |
||
| 607 | * Empty strings are treated as NULL. |
||
| 608 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 609 | */ |
||
| 610 | View Code Duplication | public function setStarted($v) |
|
| 622 | |||
| 623 | /** |
||
| 624 | * Sets the value of [stopped] column to a normalized version of the date/time value specified. |
||
| 625 | * |
||
| 626 | * @param mixed $v string, integer (timestamp), or \DateTime value. |
||
| 627 | * Empty strings are treated as NULL. |
||
| 628 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 629 | */ |
||
| 630 | View Code Duplication | public function setStopped($v) |
|
| 642 | |||
| 643 | /** |
||
| 644 | * Set the value of [title] column. |
||
| 645 | * |
||
| 646 | * @param string $v new value |
||
| 647 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 648 | */ |
||
| 649 | View Code Duplication | public function setTitle($v) |
|
| 662 | |||
| 663 | /** |
||
| 664 | * Set the value of [service] column. |
||
| 665 | * |
||
| 666 | * @param string $v new value |
||
| 667 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 668 | */ |
||
| 669 | View Code Duplication | public function setService($v) |
|
| 682 | |||
| 683 | /** |
||
| 684 | * Indicates whether the columns in this object are only set to default values. |
||
| 685 | * |
||
| 686 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
| 687 | * modified _and_ has some values set which are non-default. |
||
| 688 | * |
||
| 689 | * @return boolean Whether the columns in this object are only been set with default values. |
||
| 690 | */ |
||
| 691 | public function hasOnlyDefaultValues() |
||
| 696 | |||
| 697 | /** |
||
| 698 | * Hydrates (populates) the object variables with values from the database resultset. |
||
| 699 | * |
||
| 700 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
| 701 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
| 702 | * for results of JOIN queries where the resultset row includes columns from two or |
||
| 703 | * more tables. |
||
| 704 | * |
||
| 705 | * @param array $row The row returned by DataFetcher->fetch(). |
||
| 706 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
| 707 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
| 708 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
| 709 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 710 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 711 | * |
||
| 712 | * @return int next starting column |
||
| 713 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
| 714 | */ |
||
| 715 | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
||
| 759 | |||
| 760 | /** |
||
| 761 | * Checks and repairs the internal consistency of the object. |
||
| 762 | * |
||
| 763 | * This method is executed after an already-instantiated object is re-hydrated |
||
| 764 | * from the database. It exists to check any foreign keys to make sure that |
||
| 765 | * the objects related to the current object are correct based on foreign key. |
||
| 766 | * |
||
| 767 | * You can override this method in the stub class, but you should always invoke |
||
| 768 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
| 769 | * in case your model changes. |
||
| 770 | * |
||
| 771 | * @throws PropelException |
||
| 772 | */ |
||
| 773 | public function ensureConsistency() |
||
| 785 | |||
| 786 | /** |
||
| 787 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
| 788 | * |
||
| 789 | * This will only work if the object has been saved and has a valid primary key set. |
||
| 790 | * |
||
| 791 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
| 792 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
| 793 | * @return void |
||
| 794 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
| 795 | */ |
||
| 796 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
| 828 | |||
| 829 | /** |
||
| 830 | * Removes this object from datastore and sets delete attribute. |
||
| 831 | * |
||
| 832 | * @param ConnectionInterface $con |
||
| 833 | * @return void |
||
| 834 | * @throws PropelException |
||
| 835 | * @see Subscription::setDeleted() |
||
| 836 | * @see Subscription::isDeleted() |
||
| 837 | */ |
||
| 838 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 859 | |||
| 860 | /** |
||
| 861 | * Persists this object to the database. |
||
| 862 | * |
||
| 863 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 864 | * All modified related objects will also be persisted in the doSave() |
||
| 865 | * method. This method wraps all precipitate database operations in a |
||
| 866 | * single transaction. |
||
| 867 | * |
||
| 868 | * @param ConnectionInterface $con |
||
| 869 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 870 | * @throws PropelException |
||
| 871 | * @see doSave() |
||
| 872 | */ |
||
| 873 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
| 907 | |||
| 908 | /** |
||
| 909 | * Performs the work of inserting or updating the row in the database. |
||
| 910 | * |
||
| 911 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 912 | * All related objects are also updated in this method. |
||
| 913 | * |
||
| 914 | * @param ConnectionInterface $con |
||
| 915 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 916 | * @throws PropelException |
||
| 917 | * @see save() |
||
| 918 | */ |
||
| 919 | protected function doSave(ConnectionInterface $con) |
||
| 968 | |||
| 969 | /** |
||
| 970 | * Insert the row in the database. |
||
| 971 | * |
||
| 972 | * @param ConnectionInterface $con |
||
| 973 | * |
||
| 974 | * @throws PropelException |
||
| 975 | * @see doSave() |
||
| 976 | */ |
||
| 977 | protected function doInsert(ConnectionInterface $con) |
||
| 1070 | |||
| 1071 | /** |
||
| 1072 | * Update the row in the database. |
||
| 1073 | * |
||
| 1074 | * @param ConnectionInterface $con |
||
| 1075 | * |
||
| 1076 | * @return Integer Number of updated rows |
||
| 1077 | * @see doSave() |
||
| 1078 | */ |
||
| 1079 | protected function doUpdate(ConnectionInterface $con) |
||
| 1086 | |||
| 1087 | /** |
||
| 1088 | * Retrieves a field from the object by name passed in as a string. |
||
| 1089 | * |
||
| 1090 | * @param string $name name |
||
| 1091 | * @param string $type The type of fieldname the $name is of: |
||
| 1092 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1093 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1094 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1095 | * @return mixed Value of field. |
||
| 1096 | */ |
||
| 1097 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 1104 | |||
| 1105 | /** |
||
| 1106 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
| 1107 | * Zero-based. |
||
| 1108 | * |
||
| 1109 | * @param int $pos position in xml schema |
||
| 1110 | * @return mixed Value of field at $pos |
||
| 1111 | */ |
||
| 1112 | public function getByPosition($pos) |
||
| 1147 | |||
| 1148 | /** |
||
| 1149 | * Exports the object as an array. |
||
| 1150 | * |
||
| 1151 | * You can specify the key type of the array by passing one of the class |
||
| 1152 | * type constants. |
||
| 1153 | * |
||
| 1154 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1155 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1156 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1157 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
| 1158 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
| 1159 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
| 1160 | * |
||
| 1161 | * @return array an associative array containing the field names (as keys) and field values |
||
| 1162 | */ |
||
| 1163 | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
||
| 1245 | |||
| 1246 | /** |
||
| 1247 | * Sets a field from the object by name passed in as a string. |
||
| 1248 | * |
||
| 1249 | * @param string $name |
||
| 1250 | * @param mixed $value field value |
||
| 1251 | * @param string $type The type of fieldname the $name is of: |
||
| 1252 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1253 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1254 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1255 | * @return $this|\Jalle19\StatusManager\Database\Subscription |
||
| 1256 | */ |
||
| 1257 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
| 1263 | |||
| 1264 | /** |
||
| 1265 | * Sets a field from the object by Position as specified in the xml schema. |
||
| 1266 | * Zero-based. |
||
| 1267 | * |
||
| 1268 | * @param int $pos position in xml schema |
||
| 1269 | * @param mixed $value field value |
||
| 1270 | * @return $this|\Jalle19\StatusManager\Database\Subscription |
||
| 1271 | */ |
||
| 1272 | public function setByPosition($pos, $value) |
||
| 1306 | |||
| 1307 | /** |
||
| 1308 | * Populates the object using an array. |
||
| 1309 | * |
||
| 1310 | * This is particularly useful when populating an object from one of the |
||
| 1311 | * request arrays (e.g. $_POST). This method goes through the column |
||
| 1312 | * names, checking to see whether a matching key exists in populated |
||
| 1313 | * array. If so the setByName() method is called for that column. |
||
| 1314 | * |
||
| 1315 | * You can specify the key type of the array by additionally passing one |
||
| 1316 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1317 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1318 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1319 | * |
||
| 1320 | * @param array $arr An array to populate the object from. |
||
| 1321 | * @param string $keyType The type of keys the array uses. |
||
| 1322 | * @return void |
||
| 1323 | */ |
||
| 1324 | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
||
| 1356 | |||
| 1357 | /** |
||
| 1358 | * Populate the current object from a string, using a given parser format |
||
| 1359 | * <code> |
||
| 1360 | * $book = new Book(); |
||
| 1361 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 1362 | * </code> |
||
| 1363 | * |
||
| 1364 | * You can specify the key type of the array by additionally passing one |
||
| 1365 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1366 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1367 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1368 | * |
||
| 1369 | * @param mixed $parser A AbstractParser instance, |
||
| 1370 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 1371 | * @param string $data The source data to import from |
||
| 1372 | * @param string $keyType The type of keys the array uses. |
||
| 1373 | * |
||
| 1374 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object, for fluid interface |
||
| 1375 | */ |
||
| 1376 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1386 | |||
| 1387 | /** |
||
| 1388 | * Build a Criteria object containing the values of all modified columns in this object. |
||
| 1389 | * |
||
| 1390 | * @return Criteria The Criteria object containing all modified values. |
||
| 1391 | */ |
||
| 1392 | public function buildCriteria() |
||
| 1426 | |||
| 1427 | /** |
||
| 1428 | * Builds a Criteria object containing the primary key for this object. |
||
| 1429 | * |
||
| 1430 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
| 1431 | * of whether or not they have been modified. |
||
| 1432 | * |
||
| 1433 | * @throws LogicException if no primary key is defined |
||
| 1434 | * |
||
| 1435 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
| 1436 | */ |
||
| 1437 | public function buildPkeyCriteria() |
||
| 1444 | |||
| 1445 | /** |
||
| 1446 | * If the primary key is not null, return the hashcode of the |
||
| 1447 | * primary key. Otherwise, return the hash code of the object. |
||
| 1448 | * |
||
| 1449 | * @return int Hashcode |
||
| 1450 | */ |
||
| 1451 | View Code Duplication | public function hashCode() |
|
| 1466 | |||
| 1467 | /** |
||
| 1468 | * Returns the primary key for this object (row). |
||
| 1469 | * @return int |
||
| 1470 | */ |
||
| 1471 | public function getPrimaryKey() |
||
| 1475 | |||
| 1476 | /** |
||
| 1477 | * Generic method to set the primary key (id column). |
||
| 1478 | * |
||
| 1479 | * @param int $key Primary key. |
||
| 1480 | * @return void |
||
| 1481 | */ |
||
| 1482 | public function setPrimaryKey($key) |
||
| 1486 | |||
| 1487 | /** |
||
| 1488 | * Returns true if the primary key for this object is null. |
||
| 1489 | * @return boolean |
||
| 1490 | */ |
||
| 1491 | public function isPrimaryKeyNull() |
||
| 1495 | |||
| 1496 | /** |
||
| 1497 | * Sets contents of passed object to values from current object. |
||
| 1498 | * |
||
| 1499 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1500 | * objects. |
||
| 1501 | * |
||
| 1502 | * @param object $copyObj An object of \Jalle19\StatusManager\Database\Subscription (or compatible) type. |
||
| 1503 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1504 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
| 1505 | * @throws PropelException |
||
| 1506 | */ |
||
| 1507 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
| 1522 | |||
| 1523 | /** |
||
| 1524 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
| 1525 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
| 1526 | * keys that are defined for the table. |
||
| 1527 | * |
||
| 1528 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1529 | * objects. |
||
| 1530 | * |
||
| 1531 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1532 | * @return \Jalle19\StatusManager\Database\Subscription Clone of current object. |
||
| 1533 | * @throws PropelException |
||
| 1534 | */ |
||
| 1535 | View Code Duplication | public function copy($deepCopy = false) |
|
| 1544 | |||
| 1545 | /** |
||
| 1546 | * Declares an association between this object and a ChildInstance object. |
||
| 1547 | * |
||
| 1548 | * @param ChildInstance $v |
||
| 1549 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 1550 | * @throws PropelException |
||
| 1551 | */ |
||
| 1552 | View Code Duplication | public function setInstance(ChildInstance $v = null) |
|
| 1571 | |||
| 1572 | |||
| 1573 | /** |
||
| 1574 | * Get the associated ChildInstance object |
||
| 1575 | * |
||
| 1576 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1577 | * @return ChildInstance The associated ChildInstance object. |
||
| 1578 | * @throws PropelException |
||
| 1579 | */ |
||
| 1580 | View Code Duplication | public function getInstance(ConnectionInterface $con = null) |
|
| 1595 | |||
| 1596 | /** |
||
| 1597 | * Declares an association between this object and a ChildUser object. |
||
| 1598 | * |
||
| 1599 | * @param ChildUser $v |
||
| 1600 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 1601 | * @throws PropelException |
||
| 1602 | */ |
||
| 1603 | View Code Duplication | public function setUser(ChildUser $v = null) |
|
| 1622 | |||
| 1623 | |||
| 1624 | /** |
||
| 1625 | * Get the associated ChildUser object |
||
| 1626 | * |
||
| 1627 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1628 | * @return ChildUser The associated ChildUser object. |
||
| 1629 | * @throws PropelException |
||
| 1630 | */ |
||
| 1631 | View Code Duplication | public function getUser(ConnectionInterface $con = null) |
|
| 1646 | |||
| 1647 | /** |
||
| 1648 | * Declares an association between this object and a ChildChannel object. |
||
| 1649 | * |
||
| 1650 | * @param ChildChannel $v |
||
| 1651 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 1652 | * @throws PropelException |
||
| 1653 | */ |
||
| 1654 | View Code Duplication | public function setChannel(ChildChannel $v = null) |
|
| 1673 | |||
| 1674 | |||
| 1675 | /** |
||
| 1676 | * Get the associated ChildChannel object |
||
| 1677 | * |
||
| 1678 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1679 | * @return ChildChannel The associated ChildChannel object. |
||
| 1680 | * @throws PropelException |
||
| 1681 | */ |
||
| 1682 | public function getChannel(ConnectionInterface $con = null) |
||
| 1697 | |||
| 1698 | /** |
||
| 1699 | * Clears the current object, sets all attributes to their default values and removes |
||
| 1700 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
| 1701 | * change of those foreign objects when you call `save` there). |
||
| 1702 | */ |
||
| 1703 | public function clear() |
||
| 1729 | |||
| 1730 | /** |
||
| 1731 | * Resets all references and back-references to other model objects or collections of model objects. |
||
| 1732 | * |
||
| 1733 | * This method is used to reset all php object references (not the actual reference in the database). |
||
| 1734 | * Necessary for object serialisation. |
||
| 1735 | * |
||
| 1736 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
| 1737 | */ |
||
| 1738 | public function clearAllReferences($deep = false) |
||
| 1747 | |||
| 1748 | /** |
||
| 1749 | * Return the string representation of this object |
||
| 1750 | * |
||
| 1751 | * @return string |
||
| 1752 | */ |
||
| 1753 | public function __toString() |
||
| 1757 | |||
| 1758 | /** |
||
| 1759 | * Code to be run before persisting the object |
||
| 1760 | * @param ConnectionInterface $con |
||
| 1761 | * @return boolean |
||
| 1762 | */ |
||
| 1763 | public function preSave(ConnectionInterface $con = null) |
||
| 1767 | |||
| 1768 | /** |
||
| 1769 | * Code to be run after persisting the object |
||
| 1770 | * @param ConnectionInterface $con |
||
| 1771 | */ |
||
| 1772 | public function postSave(ConnectionInterface $con = null) |
||
| 1776 | |||
| 1777 | /** |
||
| 1778 | * Code to be run before inserting to database |
||
| 1779 | * @param ConnectionInterface $con |
||
| 1780 | * @return boolean |
||
| 1781 | */ |
||
| 1782 | public function preInsert(ConnectionInterface $con = null) |
||
| 1786 | |||
| 1787 | /** |
||
| 1788 | * Code to be run after inserting to database |
||
| 1789 | * @param ConnectionInterface $con |
||
| 1790 | */ |
||
| 1791 | public function postInsert(ConnectionInterface $con = null) |
||
| 1795 | |||
| 1796 | /** |
||
| 1797 | * Code to be run before updating the object in database |
||
| 1798 | * @param ConnectionInterface $con |
||
| 1799 | * @return boolean |
||
| 1800 | */ |
||
| 1801 | public function preUpdate(ConnectionInterface $con = null) |
||
| 1805 | |||
| 1806 | /** |
||
| 1807 | * Code to be run after updating the object in database |
||
| 1808 | * @param ConnectionInterface $con |
||
| 1809 | */ |
||
| 1810 | public function postUpdate(ConnectionInterface $con = null) |
||
| 1814 | |||
| 1815 | /** |
||
| 1816 | * Code to be run before deleting the object in database |
||
| 1817 | * @param ConnectionInterface $con |
||
| 1818 | * @return boolean |
||
| 1819 | */ |
||
| 1820 | public function preDelete(ConnectionInterface $con = null) |
||
| 1824 | |||
| 1825 | /** |
||
| 1826 | * Code to be run after deleting the object in database |
||
| 1827 | * @param ConnectionInterface $con |
||
| 1828 | */ |
||
| 1829 | public function postDelete(ConnectionInterface $con = null) |
||
| 1833 | |||
| 1834 | |||
| 1835 | /** |
||
| 1836 | * Derived method to catches calls to undefined methods. |
||
| 1837 | * |
||
| 1838 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
| 1839 | * Allows to define default __call() behavior if you overwrite __call() |
||
| 1840 | * |
||
| 1841 | * @param string $name |
||
| 1842 | * @param mixed $params |
||
| 1843 | * |
||
| 1844 | * @return array|string |
||
| 1845 | */ |
||
| 1846 | View Code Duplication | public function __call($name, $params) |
|
| 1875 | |||
| 1876 | } |
||
| 1877 |
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.