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 |
||
| 38 | abstract class Subscription implements ActiveRecordInterface |
||
| 39 | { |
||
| 40 | /** |
||
| 41 | * TableMap class name |
||
| 42 | */ |
||
| 43 | const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\SubscriptionTableMap'; |
||
| 44 | |||
| 45 | |||
| 46 | /** |
||
| 47 | * attribute to determine if this object has previously been saved. |
||
| 48 | * @var boolean |
||
| 49 | */ |
||
| 50 | protected $new = true; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * attribute to determine whether this object has been deleted. |
||
| 54 | * @var boolean |
||
| 55 | */ |
||
| 56 | protected $deleted = false; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * The columns that have been modified in current object. |
||
| 60 | * Tracking modified columns allows us to only update modified columns. |
||
| 61 | * @var array |
||
| 62 | */ |
||
| 63 | protected $modifiedColumns = array(); |
||
| 64 | |||
| 65 | /** |
||
| 66 | * The (virtual) columns that are added at runtime |
||
| 67 | * The formatters can add supplementary columns based on a resultset |
||
| 68 | * @var array |
||
| 69 | */ |
||
| 70 | protected $virtualColumns = array(); |
||
| 71 | |||
| 72 | /** |
||
| 73 | * The value for the id field. |
||
| 74 | * |
||
| 75 | * @var int |
||
| 76 | */ |
||
| 77 | protected $id; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * The value for the instance_name field. |
||
| 81 | * |
||
| 82 | * @var string |
||
| 83 | */ |
||
| 84 | protected $instance_name; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * The value for the input_uuid field. |
||
| 88 | * |
||
| 89 | * @var string |
||
| 90 | */ |
||
| 91 | protected $input_uuid; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * The value for the user_id field. |
||
| 95 | * |
||
| 96 | * @var int |
||
| 97 | */ |
||
| 98 | protected $user_id; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * The value for the channel_id field. |
||
| 102 | * |
||
| 103 | * @var int |
||
| 104 | */ |
||
| 105 | protected $channel_id; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * The value for the subscription_id field. |
||
| 109 | * |
||
| 110 | * @var int |
||
| 111 | */ |
||
| 112 | protected $subscription_id; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * The value for the started field. |
||
| 116 | * |
||
| 117 | * @var \DateTime |
||
| 118 | */ |
||
| 119 | protected $started; |
||
| 120 | |||
| 121 | /** |
||
| 122 | * The value for the stopped field. |
||
| 123 | * |
||
| 124 | * @var \DateTime |
||
| 125 | */ |
||
| 126 | protected $stopped; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * The value for the title field. |
||
| 130 | * |
||
| 131 | * @var string |
||
| 132 | */ |
||
| 133 | protected $title; |
||
| 134 | |||
| 135 | /** |
||
| 136 | * The value for the service field. |
||
| 137 | * |
||
| 138 | * @var string |
||
| 139 | */ |
||
| 140 | protected $service; |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @var ChildInstance |
||
| 144 | */ |
||
| 145 | protected $aInstance; |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @var ChildInput |
||
| 149 | */ |
||
| 150 | protected $aInput; |
||
| 151 | |||
| 152 | /** |
||
| 153 | * @var ChildUser |
||
| 154 | */ |
||
| 155 | protected $aUser; |
||
| 156 | |||
| 157 | /** |
||
| 158 | * @var ChildChannel |
||
| 159 | */ |
||
| 160 | protected $aChannel; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * Flag to prevent endless save loop, if this object is referenced |
||
| 164 | * by another object which falls in this transaction. |
||
| 165 | * |
||
| 166 | * @var boolean |
||
| 167 | */ |
||
| 168 | protected $alreadyInSave = false; |
||
| 169 | |||
| 170 | /** |
||
| 171 | * Initializes internal state of Jalle19\StatusManager\Database\Base\Subscription object. |
||
| 172 | */ |
||
| 173 | public function __construct() |
||
| 176 | |||
| 177 | /** |
||
| 178 | * Returns whether the object has been modified. |
||
| 179 | * |
||
| 180 | * @return boolean True if the object has been modified. |
||
| 181 | */ |
||
| 182 | public function isModified() |
||
| 186 | |||
| 187 | /** |
||
| 188 | * Has specified column been modified? |
||
| 189 | * |
||
| 190 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
| 191 | * @return boolean True if $col has been modified. |
||
| 192 | */ |
||
| 193 | public function isColumnModified($col) |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Get the columns that have been modified in this object. |
||
| 200 | * @return array A unique list of the modified column names for this object. |
||
| 201 | */ |
||
| 202 | public function getModifiedColumns() |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Returns whether the object has ever been saved. This will |
||
| 209 | * be false, if the object was retrieved from storage or was created |
||
| 210 | * and then saved. |
||
| 211 | * |
||
| 212 | * @return boolean true, if the object has never been persisted. |
||
| 213 | */ |
||
| 214 | public function isNew() |
||
| 218 | |||
| 219 | /** |
||
| 220 | * Setter for the isNew attribute. This method will be called |
||
| 221 | * by Propel-generated children and objects. |
||
| 222 | * |
||
| 223 | * @param boolean $b the state of the object. |
||
| 224 | */ |
||
| 225 | public function setNew($b) |
||
| 229 | |||
| 230 | /** |
||
| 231 | * Whether this object has been deleted. |
||
| 232 | * @return boolean The deleted state of this object. |
||
| 233 | */ |
||
| 234 | public function isDeleted() |
||
| 238 | |||
| 239 | /** |
||
| 240 | * Specify whether this object has been deleted. |
||
| 241 | * @param boolean $b The deleted state of this object. |
||
| 242 | * @return void |
||
| 243 | */ |
||
| 244 | public function setDeleted($b) |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Sets the modified state for the object to be false. |
||
| 251 | * @param string $col If supplied, only the specified column is reset. |
||
| 252 | * @return void |
||
| 253 | */ |
||
| 254 | View Code Duplication | public function resetModified($col = null) |
|
| 264 | |||
| 265 | /** |
||
| 266 | * Compares this with another <code>Subscription</code> instance. If |
||
| 267 | * <code>obj</code> is an instance of <code>Subscription</code>, delegates to |
||
| 268 | * <code>equals(Subscription)</code>. Otherwise, returns <code>false</code>. |
||
| 269 | * |
||
| 270 | * @param mixed $obj The object to compare to. |
||
| 271 | * @return boolean Whether equal to the object specified. |
||
| 272 | */ |
||
| 273 | View Code Duplication | public function equals($obj) |
|
| 289 | |||
| 290 | /** |
||
| 291 | * Get the associative array of the virtual columns in this object |
||
| 292 | * |
||
| 293 | * @return array |
||
| 294 | */ |
||
| 295 | public function getVirtualColumns() |
||
| 299 | |||
| 300 | /** |
||
| 301 | * Checks the existence of a virtual column in this object |
||
| 302 | * |
||
| 303 | * @param string $name The virtual column name |
||
| 304 | * @return boolean |
||
| 305 | */ |
||
| 306 | public function hasVirtualColumn($name) |
||
| 310 | |||
| 311 | /** |
||
| 312 | * Get the value of a virtual column in this object |
||
| 313 | * |
||
| 314 | * @param string $name The virtual column name |
||
| 315 | * @return mixed |
||
| 316 | * |
||
| 317 | * @throws PropelException |
||
| 318 | */ |
||
| 319 | View Code Duplication | public function getVirtualColumn($name) |
|
| 327 | |||
| 328 | /** |
||
| 329 | * Set the value of a virtual column in this object |
||
| 330 | * |
||
| 331 | * @param string $name The virtual column name |
||
| 332 | * @param mixed $value The value to give to the virtual column |
||
| 333 | * |
||
| 334 | * @return $this|Subscription The current object, for fluid interface |
||
| 335 | */ |
||
| 336 | public function setVirtualColumn($name, $value) |
||
| 342 | |||
| 343 | /** |
||
| 344 | * Logs a message using Propel::log(). |
||
| 345 | * |
||
| 346 | * @param string $msg |
||
| 347 | * @param int $priority One of the Propel::LOG_* logging levels |
||
| 348 | * @return boolean |
||
| 349 | */ |
||
| 350 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
| 354 | |||
| 355 | /** |
||
| 356 | * Export the current object properties to a string, using a given parser format |
||
| 357 | * <code> |
||
| 358 | * $book = BookQuery::create()->findPk(9012); |
||
| 359 | * echo $book->exportTo('JSON'); |
||
| 360 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 361 | * </code> |
||
| 362 | * |
||
| 363 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 364 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
| 365 | * @return string The exported data |
||
| 366 | */ |
||
| 367 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 375 | |||
| 376 | /** |
||
| 377 | * Clean up internal collections prior to serializing |
||
| 378 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
| 379 | */ |
||
| 380 | View Code Duplication | public function __sleep() |
|
| 394 | |||
| 395 | /** |
||
| 396 | * Get the [id] column value. |
||
| 397 | * |
||
| 398 | * @return int |
||
| 399 | */ |
||
| 400 | public function getId() |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Get the [instance_name] column value. |
||
| 407 | * |
||
| 408 | * @return string |
||
| 409 | */ |
||
| 410 | public function getInstanceName() |
||
| 414 | |||
| 415 | /** |
||
| 416 | * Get the [input_uuid] column value. |
||
| 417 | * |
||
| 418 | * @return string |
||
| 419 | */ |
||
| 420 | public function getInputUuid() |
||
| 424 | |||
| 425 | /** |
||
| 426 | * Get the [user_id] column value. |
||
| 427 | * |
||
| 428 | * @return int |
||
| 429 | */ |
||
| 430 | public function getUserId() |
||
| 434 | |||
| 435 | /** |
||
| 436 | * Get the [channel_id] column value. |
||
| 437 | * |
||
| 438 | * @return int |
||
| 439 | */ |
||
| 440 | public function getChannelId() |
||
| 444 | |||
| 445 | /** |
||
| 446 | * Get the [subscription_id] column value. |
||
| 447 | * |
||
| 448 | * @return int |
||
| 449 | */ |
||
| 450 | public function getSubscriptionId() |
||
| 454 | |||
| 455 | /** |
||
| 456 | * Get the [optionally formatted] temporal [started] column value. |
||
| 457 | * |
||
| 458 | * |
||
| 459 | * @param string $format The date/time format string (either date()-style or strftime()-style). |
||
| 460 | * If format is NULL, then the raw DateTime object will be returned. |
||
| 461 | * |
||
| 462 | * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
||
| 463 | * |
||
| 464 | * @throws PropelException - if unable to parse/validate the date/time value. |
||
| 465 | */ |
||
| 466 | View Code Duplication | public function getStarted($format = NULL) |
|
| 474 | |||
| 475 | /** |
||
| 476 | * Get the [optionally formatted] temporal [stopped] column value. |
||
| 477 | * |
||
| 478 | * |
||
| 479 | * @param string $format The date/time format string (either date()-style or strftime()-style). |
||
| 480 | * If format is NULL, then the raw DateTime object will be returned. |
||
| 481 | * |
||
| 482 | * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
||
| 483 | * |
||
| 484 | * @throws PropelException - if unable to parse/validate the date/time value. |
||
| 485 | */ |
||
| 486 | public function getStopped($format = NULL) |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Get the [title] column value. |
||
| 497 | * |
||
| 498 | * @return string |
||
| 499 | */ |
||
| 500 | public function getTitle() |
||
| 504 | |||
| 505 | /** |
||
| 506 | * Get the [service] column value. |
||
| 507 | * |
||
| 508 | * @return string |
||
| 509 | */ |
||
| 510 | public function getService() |
||
| 514 | |||
| 515 | /** |
||
| 516 | * Set the value of [id] column. |
||
| 517 | * |
||
| 518 | * @param int $v new value |
||
| 519 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 520 | */ |
||
| 521 | View Code Duplication | public function setId($v) |
|
| 534 | |||
| 535 | /** |
||
| 536 | * Set the value of [instance_name] column. |
||
| 537 | * |
||
| 538 | * @param string $v new value |
||
| 539 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 540 | */ |
||
| 541 | View Code Duplication | public function setInstanceName($v) |
|
| 558 | |||
| 559 | /** |
||
| 560 | * Set the value of [input_uuid] column. |
||
| 561 | * |
||
| 562 | * @param string $v new value |
||
| 563 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 564 | */ |
||
| 565 | View Code Duplication | public function setInputUuid($v) |
|
| 582 | |||
| 583 | /** |
||
| 584 | * Set the value of [user_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 setUserId($v) |
|
| 606 | |||
| 607 | /** |
||
| 608 | * Set the value of [channel_id] column. |
||
| 609 | * |
||
| 610 | * @param int $v new value |
||
| 611 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 612 | */ |
||
| 613 | View Code Duplication | public function setChannelId($v) |
|
| 630 | |||
| 631 | /** |
||
| 632 | * Set the value of [subscription_id] column. |
||
| 633 | * |
||
| 634 | * @param int $v new value |
||
| 635 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 636 | */ |
||
| 637 | View Code Duplication | public function setSubscriptionId($v) |
|
| 650 | |||
| 651 | /** |
||
| 652 | * Sets the value of [started] column to a normalized version of the date/time value specified. |
||
| 653 | * |
||
| 654 | * @param mixed $v string, integer (timestamp), or \DateTime value. |
||
| 655 | * Empty strings are treated as NULL. |
||
| 656 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 657 | */ |
||
| 658 | View Code Duplication | public function setStarted($v) |
|
| 670 | |||
| 671 | /** |
||
| 672 | * Sets the value of [stopped] column to a normalized version of the date/time value specified. |
||
| 673 | * |
||
| 674 | * @param mixed $v string, integer (timestamp), or \DateTime value. |
||
| 675 | * Empty strings are treated as NULL. |
||
| 676 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 677 | */ |
||
| 678 | View Code Duplication | public function setStopped($v) |
|
| 690 | |||
| 691 | /** |
||
| 692 | * Set the value of [title] column. |
||
| 693 | * |
||
| 694 | * @param string $v new value |
||
| 695 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 696 | */ |
||
| 697 | View Code Duplication | public function setTitle($v) |
|
| 710 | |||
| 711 | /** |
||
| 712 | * Set the value of [service] column. |
||
| 713 | * |
||
| 714 | * @param string $v new value |
||
| 715 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 716 | */ |
||
| 717 | View Code Duplication | public function setService($v) |
|
| 730 | |||
| 731 | /** |
||
| 732 | * Indicates whether the columns in this object are only set to default values. |
||
| 733 | * |
||
| 734 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
| 735 | * modified _and_ has some values set which are non-default. |
||
| 736 | * |
||
| 737 | * @return boolean Whether the columns in this object are only been set with default values. |
||
| 738 | */ |
||
| 739 | public function hasOnlyDefaultValues() |
||
| 744 | |||
| 745 | /** |
||
| 746 | * Hydrates (populates) the object variables with values from the database resultset. |
||
| 747 | * |
||
| 748 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
| 749 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
| 750 | * for results of JOIN queries where the resultset row includes columns from two or |
||
| 751 | * more tables. |
||
| 752 | * |
||
| 753 | * @param array $row The row returned by DataFetcher->fetch(). |
||
| 754 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
| 755 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
| 756 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
| 757 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 758 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 759 | * |
||
| 760 | * @return int next starting column |
||
| 761 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
| 762 | */ |
||
| 763 | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
||
| 810 | |||
| 811 | /** |
||
| 812 | * Checks and repairs the internal consistency of the object. |
||
| 813 | * |
||
| 814 | * This method is executed after an already-instantiated object is re-hydrated |
||
| 815 | * from the database. It exists to check any foreign keys to make sure that |
||
| 816 | * the objects related to the current object are correct based on foreign key. |
||
| 817 | * |
||
| 818 | * You can override this method in the stub class, but you should always invoke |
||
| 819 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
| 820 | * in case your model changes. |
||
| 821 | * |
||
| 822 | * @throws PropelException |
||
| 823 | */ |
||
| 824 | public function ensureConsistency() |
||
| 839 | |||
| 840 | /** |
||
| 841 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
| 842 | * |
||
| 843 | * This will only work if the object has been saved and has a valid primary key set. |
||
| 844 | * |
||
| 845 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
| 846 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
| 847 | * @return void |
||
| 848 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
| 849 | */ |
||
| 850 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
| 883 | |||
| 884 | /** |
||
| 885 | * Removes this object from datastore and sets delete attribute. |
||
| 886 | * |
||
| 887 | * @param ConnectionInterface $con |
||
| 888 | * @return void |
||
| 889 | * @throws PropelException |
||
| 890 | * @see Subscription::setDeleted() |
||
| 891 | * @see Subscription::isDeleted() |
||
| 892 | */ |
||
| 893 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 914 | |||
| 915 | /** |
||
| 916 | * Persists this object to the database. |
||
| 917 | * |
||
| 918 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 919 | * All modified related objects will also be persisted in the doSave() |
||
| 920 | * method. This method wraps all precipitate database operations in a |
||
| 921 | * single transaction. |
||
| 922 | * |
||
| 923 | * @param ConnectionInterface $con |
||
| 924 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 925 | * @throws PropelException |
||
| 926 | * @see doSave() |
||
| 927 | */ |
||
| 928 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
| 962 | |||
| 963 | /** |
||
| 964 | * Performs the work of inserting or updating the row in the database. |
||
| 965 | * |
||
| 966 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 967 | * All related objects are also updated in this method. |
||
| 968 | * |
||
| 969 | * @param ConnectionInterface $con |
||
| 970 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 971 | * @throws PropelException |
||
| 972 | * @see save() |
||
| 973 | */ |
||
| 974 | protected function doSave(ConnectionInterface $con) |
||
| 1030 | |||
| 1031 | /** |
||
| 1032 | * Insert the row in the database. |
||
| 1033 | * |
||
| 1034 | * @param ConnectionInterface $con |
||
| 1035 | * |
||
| 1036 | * @throws PropelException |
||
| 1037 | * @see doSave() |
||
| 1038 | */ |
||
| 1039 | protected function doInsert(ConnectionInterface $con) |
||
| 1138 | |||
| 1139 | /** |
||
| 1140 | * Update the row in the database. |
||
| 1141 | * |
||
| 1142 | * @param ConnectionInterface $con |
||
| 1143 | * |
||
| 1144 | * @return Integer Number of updated rows |
||
| 1145 | * @see doSave() |
||
| 1146 | */ |
||
| 1147 | protected function doUpdate(ConnectionInterface $con) |
||
| 1154 | |||
| 1155 | /** |
||
| 1156 | * Retrieves a field from the object by name passed in as a string. |
||
| 1157 | * |
||
| 1158 | * @param string $name name |
||
| 1159 | * @param string $type The type of fieldname the $name is of: |
||
| 1160 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1161 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1162 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1163 | * @return mixed Value of field. |
||
| 1164 | */ |
||
| 1165 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 1172 | |||
| 1173 | /** |
||
| 1174 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
| 1175 | * Zero-based. |
||
| 1176 | * |
||
| 1177 | * @param int $pos position in xml schema |
||
| 1178 | * @return mixed Value of field at $pos |
||
| 1179 | */ |
||
| 1180 | public function getByPosition($pos) |
||
| 1218 | |||
| 1219 | /** |
||
| 1220 | * Exports the object as an array. |
||
| 1221 | * |
||
| 1222 | * You can specify the key type of the array by passing one of the class |
||
| 1223 | * type constants. |
||
| 1224 | * |
||
| 1225 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1226 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1227 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1228 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
| 1229 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
| 1230 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
| 1231 | * |
||
| 1232 | * @return array an associative array containing the field names (as keys) and field values |
||
| 1233 | */ |
||
| 1234 | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
||
| 1332 | |||
| 1333 | /** |
||
| 1334 | * Sets a field from the object by name passed in as a string. |
||
| 1335 | * |
||
| 1336 | * @param string $name |
||
| 1337 | * @param mixed $value field value |
||
| 1338 | * @param string $type The type of fieldname the $name is of: |
||
| 1339 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1340 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1341 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1342 | * @return $this|\Jalle19\StatusManager\Database\Subscription |
||
| 1343 | */ |
||
| 1344 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
| 1350 | |||
| 1351 | /** |
||
| 1352 | * Sets a field from the object by Position as specified in the xml schema. |
||
| 1353 | * Zero-based. |
||
| 1354 | * |
||
| 1355 | * @param int $pos position in xml schema |
||
| 1356 | * @param mixed $value field value |
||
| 1357 | * @return $this|\Jalle19\StatusManager\Database\Subscription |
||
| 1358 | */ |
||
| 1359 | public function setByPosition($pos, $value) |
||
| 1396 | |||
| 1397 | /** |
||
| 1398 | * Populates the object using an array. |
||
| 1399 | * |
||
| 1400 | * This is particularly useful when populating an object from one of the |
||
| 1401 | * request arrays (e.g. $_POST). This method goes through the column |
||
| 1402 | * names, checking to see whether a matching key exists in populated |
||
| 1403 | * array. If so the setByName() method is called for that column. |
||
| 1404 | * |
||
| 1405 | * You can specify the key type of the array by additionally passing one |
||
| 1406 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1407 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1408 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1409 | * |
||
| 1410 | * @param array $arr An array to populate the object from. |
||
| 1411 | * @param string $keyType The type of keys the array uses. |
||
| 1412 | * @return void |
||
| 1413 | */ |
||
| 1414 | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
||
| 1449 | |||
| 1450 | /** |
||
| 1451 | * Populate the current object from a string, using a given parser format |
||
| 1452 | * <code> |
||
| 1453 | * $book = new Book(); |
||
| 1454 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 1455 | * </code> |
||
| 1456 | * |
||
| 1457 | * You can specify the key type of the array by additionally passing one |
||
| 1458 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1459 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1460 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1461 | * |
||
| 1462 | * @param mixed $parser A AbstractParser instance, |
||
| 1463 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 1464 | * @param string $data The source data to import from |
||
| 1465 | * @param string $keyType The type of keys the array uses. |
||
| 1466 | * |
||
| 1467 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object, for fluid interface |
||
| 1468 | */ |
||
| 1469 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1479 | |||
| 1480 | /** |
||
| 1481 | * Build a Criteria object containing the values of all modified columns in this object. |
||
| 1482 | * |
||
| 1483 | * @return Criteria The Criteria object containing all modified values. |
||
| 1484 | */ |
||
| 1485 | public function buildCriteria() |
||
| 1522 | |||
| 1523 | /** |
||
| 1524 | * Builds a Criteria object containing the primary key for this object. |
||
| 1525 | * |
||
| 1526 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
| 1527 | * of whether or not they have been modified. |
||
| 1528 | * |
||
| 1529 | * @throws LogicException if no primary key is defined |
||
| 1530 | * |
||
| 1531 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
| 1532 | */ |
||
| 1533 | public function buildPkeyCriteria() |
||
| 1540 | |||
| 1541 | /** |
||
| 1542 | * If the primary key is not null, return the hashcode of the |
||
| 1543 | * primary key. Otherwise, return the hash code of the object. |
||
| 1544 | * |
||
| 1545 | * @return int Hashcode |
||
| 1546 | */ |
||
| 1547 | View Code Duplication | public function hashCode() |
|
| 1562 | |||
| 1563 | /** |
||
| 1564 | * Returns the primary key for this object (row). |
||
| 1565 | * @return int |
||
| 1566 | */ |
||
| 1567 | public function getPrimaryKey() |
||
| 1571 | |||
| 1572 | /** |
||
| 1573 | * Generic method to set the primary key (id column). |
||
| 1574 | * |
||
| 1575 | * @param int $key Primary key. |
||
| 1576 | * @return void |
||
| 1577 | */ |
||
| 1578 | public function setPrimaryKey($key) |
||
| 1582 | |||
| 1583 | /** |
||
| 1584 | * Returns true if the primary key for this object is null. |
||
| 1585 | * @return boolean |
||
| 1586 | */ |
||
| 1587 | public function isPrimaryKeyNull() |
||
| 1591 | |||
| 1592 | /** |
||
| 1593 | * Sets contents of passed object to values from current object. |
||
| 1594 | * |
||
| 1595 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1596 | * objects. |
||
| 1597 | * |
||
| 1598 | * @param object $copyObj An object of \Jalle19\StatusManager\Database\Subscription (or compatible) type. |
||
| 1599 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1600 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
| 1601 | * @throws PropelException |
||
| 1602 | */ |
||
| 1603 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
| 1619 | |||
| 1620 | /** |
||
| 1621 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
| 1622 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
| 1623 | * keys that are defined for the table. |
||
| 1624 | * |
||
| 1625 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1626 | * objects. |
||
| 1627 | * |
||
| 1628 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1629 | * @return \Jalle19\StatusManager\Database\Subscription Clone of current object. |
||
| 1630 | * @throws PropelException |
||
| 1631 | */ |
||
| 1632 | View Code Duplication | public function copy($deepCopy = false) |
|
| 1641 | |||
| 1642 | /** |
||
| 1643 | * Declares an association between this object and a ChildInstance object. |
||
| 1644 | * |
||
| 1645 | * @param ChildInstance $v |
||
| 1646 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 1647 | * @throws PropelException |
||
| 1648 | */ |
||
| 1649 | View Code Duplication | public function setInstance(ChildInstance $v = null) |
|
| 1668 | |||
| 1669 | |||
| 1670 | /** |
||
| 1671 | * Get the associated ChildInstance object |
||
| 1672 | * |
||
| 1673 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1674 | * @return ChildInstance The associated ChildInstance object. |
||
| 1675 | * @throws PropelException |
||
| 1676 | */ |
||
| 1677 | View Code Duplication | public function getInstance(ConnectionInterface $con = null) |
|
| 1692 | |||
| 1693 | /** |
||
| 1694 | * Declares an association between this object and a ChildInput object. |
||
| 1695 | * |
||
| 1696 | * @param ChildInput $v |
||
| 1697 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 1698 | * @throws PropelException |
||
| 1699 | */ |
||
| 1700 | public function setInput(ChildInput $v = null) |
||
| 1719 | |||
| 1720 | |||
| 1721 | /** |
||
| 1722 | * Get the associated ChildInput object |
||
| 1723 | * |
||
| 1724 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1725 | * @return ChildInput The associated ChildInput object. |
||
| 1726 | * @throws PropelException |
||
| 1727 | */ |
||
| 1728 | public function getInput(ConnectionInterface $con = null) |
||
| 1743 | |||
| 1744 | /** |
||
| 1745 | * Declares an association between this object and a ChildUser object. |
||
| 1746 | * |
||
| 1747 | * @param ChildUser $v |
||
| 1748 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 1749 | * @throws PropelException |
||
| 1750 | */ |
||
| 1751 | View Code Duplication | public function setUser(ChildUser $v = null) |
|
| 1770 | |||
| 1771 | |||
| 1772 | /** |
||
| 1773 | * Get the associated ChildUser object |
||
| 1774 | * |
||
| 1775 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1776 | * @return ChildUser The associated ChildUser object. |
||
| 1777 | * @throws PropelException |
||
| 1778 | */ |
||
| 1779 | View Code Duplication | public function getUser(ConnectionInterface $con = null) |
|
| 1794 | |||
| 1795 | /** |
||
| 1796 | * Declares an association between this object and a ChildChannel object. |
||
| 1797 | * |
||
| 1798 | * @param ChildChannel $v |
||
| 1799 | * @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
||
| 1800 | * @throws PropelException |
||
| 1801 | */ |
||
| 1802 | View Code Duplication | public function setChannel(ChildChannel $v = null) |
|
| 1821 | |||
| 1822 | |||
| 1823 | /** |
||
| 1824 | * Get the associated ChildChannel object |
||
| 1825 | * |
||
| 1826 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1827 | * @return ChildChannel The associated ChildChannel object. |
||
| 1828 | * @throws PropelException |
||
| 1829 | */ |
||
| 1830 | public function getChannel(ConnectionInterface $con = null) |
||
| 1845 | |||
| 1846 | /** |
||
| 1847 | * Clears the current object, sets all attributes to their default values and removes |
||
| 1848 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
| 1849 | * change of those foreign objects when you call `save` there). |
||
| 1850 | */ |
||
| 1851 | public function clear() |
||
| 1881 | |||
| 1882 | /** |
||
| 1883 | * Resets all references and back-references to other model objects or collections of model objects. |
||
| 1884 | * |
||
| 1885 | * This method is used to reset all php object references (not the actual reference in the database). |
||
| 1886 | * Necessary for object serialisation. |
||
| 1887 | * |
||
| 1888 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
| 1889 | */ |
||
| 1890 | public function clearAllReferences($deep = false) |
||
| 1900 | |||
| 1901 | /** |
||
| 1902 | * Return the string representation of this object |
||
| 1903 | * |
||
| 1904 | * @return string |
||
| 1905 | */ |
||
| 1906 | public function __toString() |
||
| 1910 | |||
| 1911 | /** |
||
| 1912 | * Code to be run before persisting the object |
||
| 1913 | * @param ConnectionInterface $con |
||
| 1914 | * @return boolean |
||
| 1915 | */ |
||
| 1916 | public function preSave(ConnectionInterface $con = null) |
||
| 1920 | |||
| 1921 | /** |
||
| 1922 | * Code to be run after persisting the object |
||
| 1923 | * @param ConnectionInterface $con |
||
| 1924 | */ |
||
| 1925 | public function postSave(ConnectionInterface $con = null) |
||
| 1929 | |||
| 1930 | /** |
||
| 1931 | * Code to be run before inserting to database |
||
| 1932 | * @param ConnectionInterface $con |
||
| 1933 | * @return boolean |
||
| 1934 | */ |
||
| 1935 | public function preInsert(ConnectionInterface $con = null) |
||
| 1939 | |||
| 1940 | /** |
||
| 1941 | * Code to be run after inserting to database |
||
| 1942 | * @param ConnectionInterface $con |
||
| 1943 | */ |
||
| 1944 | public function postInsert(ConnectionInterface $con = null) |
||
| 1948 | |||
| 1949 | /** |
||
| 1950 | * Code to be run before updating the object in database |
||
| 1951 | * @param ConnectionInterface $con |
||
| 1952 | * @return boolean |
||
| 1953 | */ |
||
| 1954 | public function preUpdate(ConnectionInterface $con = null) |
||
| 1958 | |||
| 1959 | /** |
||
| 1960 | * Code to be run after updating the object in database |
||
| 1961 | * @param ConnectionInterface $con |
||
| 1962 | */ |
||
| 1963 | public function postUpdate(ConnectionInterface $con = null) |
||
| 1967 | |||
| 1968 | /** |
||
| 1969 | * Code to be run before deleting the object in database |
||
| 1970 | * @param ConnectionInterface $con |
||
| 1971 | * @return boolean |
||
| 1972 | */ |
||
| 1973 | public function preDelete(ConnectionInterface $con = null) |
||
| 1977 | |||
| 1978 | /** |
||
| 1979 | * Code to be run after deleting the object in database |
||
| 1980 | * @param ConnectionInterface $con |
||
| 1981 | */ |
||
| 1982 | public function postDelete(ConnectionInterface $con = null) |
||
| 1986 | |||
| 1987 | |||
| 1988 | /** |
||
| 1989 | * Derived method to catches calls to undefined methods. |
||
| 1990 | * |
||
| 1991 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
| 1992 | * Allows to define default __call() behavior if you overwrite __call() |
||
| 1993 | * |
||
| 1994 | * @param string $name |
||
| 1995 | * @param mixed $params |
||
| 1996 | * |
||
| 1997 | * @return array|string |
||
| 1998 | */ |
||
| 1999 | View Code Duplication | public function __call($name, $params) |
|
| 2028 | |||
| 2029 | } |
||
| 2030 |
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.