Complex classes like EntityMap 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 EntityMap, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 24 | class EntityMap |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * The mapping driver to use with this entity |
||
| 28 | * |
||
| 29 | * @var string |
||
| 30 | */ |
||
| 31 | protected $driver = 'illuminate'; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * The Database Connection name for the model. |
||
| 35 | * |
||
| 36 | * @var string |
||
| 37 | */ |
||
| 38 | protected $connection; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * The table associated with the entity. |
||
| 42 | * |
||
| 43 | * @var string|null |
||
| 44 | */ |
||
| 45 | protected $table = null; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * The primary key for the model. |
||
| 49 | * |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | protected $primaryKey = 'id'; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Name of the entity's array property that should |
||
| 56 | * contain the attributes |
||
| 57 | * |
||
| 58 | * @var string |
||
| 59 | */ |
||
| 60 | protected $arrayName = 'attributes'; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Array containing the list of database columns to be mapped |
||
| 64 | * in the attributes array of the entity. |
||
| 65 | * |
||
| 66 | * @var array |
||
| 67 | */ |
||
| 68 | protected $attributes = []; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Array containing the list of database columns to be mapped |
||
| 72 | * to the entity's class properties. |
||
| 73 | * |
||
| 74 | * @var array |
||
| 75 | */ |
||
| 76 | protected $properties = []; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * The Custom Domain Class to use with this mapping |
||
| 80 | * |
||
| 81 | * @var string|null |
||
| 82 | */ |
||
| 83 | protected $class = null; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Embedded Value Objects |
||
| 87 | * |
||
| 88 | * @var array |
||
| 89 | */ |
||
| 90 | protected $embeddables = []; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Determine the relationships method used on the entity. |
||
| 94 | * If not set, mapper will autodetect them |
||
| 95 | * |
||
| 96 | * @var array |
||
| 97 | */ |
||
| 98 | private $relationships = []; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Relationships that should be treated as collection. |
||
| 102 | * |
||
| 103 | * @var array |
||
| 104 | */ |
||
| 105 | private $manyRelations = []; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Relationships that should be treated as single entity. |
||
| 109 | * |
||
| 110 | * @var array |
||
| 111 | */ |
||
| 112 | private $singleRelations = []; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * Relationships for which the key is stored in the Entity itself |
||
| 116 | * |
||
| 117 | * @var array |
||
| 118 | */ |
||
| 119 | private $localRelations = []; |
||
| 120 | |||
| 121 | /** |
||
| 122 | * List of local keys associated to local relation methods |
||
| 123 | * |
||
| 124 | * @var array |
||
| 125 | */ |
||
| 126 | private $localForeignKeys = []; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * Relationships for which the key is stored in the Related Entity |
||
| 130 | * |
||
| 131 | * @var array |
||
| 132 | */ |
||
| 133 | private $foreignRelations = []; |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Relationships which use a pivot record. |
||
| 137 | * |
||
| 138 | * @var array |
||
| 139 | */ |
||
| 140 | private $pivotRelations = []; |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Dynamic relationships |
||
| 144 | * |
||
| 145 | * @var array |
||
| 146 | */ |
||
| 147 | private $dynamicRelationships = []; |
||
| 148 | |||
| 149 | /** |
||
| 150 | * Targetted class for the relationship method. value is set to `null` for |
||
| 151 | * polymorphic relations. |
||
| 152 | * |
||
| 153 | * @var array |
||
| 154 | */ |
||
| 155 | private $relatedClasses = []; |
||
| 156 | |||
| 157 | /** |
||
| 158 | * Some relation methods like embedded objects, or HasOne and MorphOne, |
||
| 159 | * will never have a proxy loaded on them. |
||
| 160 | * |
||
| 161 | * @var array |
||
| 162 | */ |
||
| 163 | private $nonProxyRelationships = []; |
||
| 164 | |||
| 165 | /** |
||
| 166 | * The number of models to return for pagination. |
||
| 167 | * |
||
| 168 | * @var int |
||
| 169 | */ |
||
| 170 | protected $perPage = 15; |
||
| 171 | |||
| 172 | /** |
||
| 173 | * The relations to eager load on every query. |
||
| 174 | * |
||
| 175 | * @var array |
||
| 176 | */ |
||
| 177 | protected $with = []; |
||
| 178 | |||
| 179 | /** |
||
| 180 | * The class name to be used in polymorphic relations. |
||
| 181 | * |
||
| 182 | * @var string |
||
| 183 | */ |
||
| 184 | protected $morphClass; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * Sequence name, to be used with postgreSql |
||
| 188 | * defaults to %table_name%_id_seq |
||
| 189 | * |
||
| 190 | * @var string|null |
||
| 191 | */ |
||
| 192 | protected $sequence = null; |
||
| 193 | |||
| 194 | /** |
||
| 195 | * Indicates if the entity should be timestamped. |
||
| 196 | * |
||
| 197 | * @var bool |
||
| 198 | */ |
||
| 199 | public $timestamps = false; |
||
| 200 | |||
| 201 | /** |
||
| 202 | * The name of the "created at" column. |
||
| 203 | * |
||
| 204 | * @var string |
||
| 205 | */ |
||
| 206 | protected $createdAtColumn = 'created_at'; |
||
| 207 | |||
| 208 | /** |
||
| 209 | * The name of the "updated at" column. |
||
| 210 | * |
||
| 211 | * @var string |
||
| 212 | */ |
||
| 213 | protected $updatedAtColumn = 'updated_at'; |
||
| 214 | |||
| 215 | /** |
||
| 216 | * Indicates if the entity uses softdeletes |
||
| 217 | * |
||
| 218 | * @var boolean |
||
| 219 | */ |
||
| 220 | public $softDeletes = false; |
||
| 221 | |||
| 222 | /** |
||
| 223 | * The name of the "deleted at" column. |
||
| 224 | * |
||
| 225 | * @var string |
||
| 226 | */ |
||
| 227 | protected $deletedAtColumn = 'deleted_at'; |
||
| 228 | |||
| 229 | /** |
||
| 230 | * The date format to use with the current database connection |
||
| 231 | * |
||
| 232 | * @var string |
||
| 233 | */ |
||
| 234 | protected $dateFormat; |
||
| 235 | |||
| 236 | /** |
||
| 237 | * Set this property to true if the entity should be instantiated |
||
| 238 | * using the IoC Container |
||
| 239 | * |
||
| 240 | * @var boolean |
||
| 241 | */ |
||
| 242 | protected $dependencyInjection = false; |
||
| 243 | |||
| 244 | /** |
||
| 245 | * Set the usage of inheritance, possible values are : |
||
| 246 | * "single_table" |
||
| 247 | * null |
||
| 248 | * |
||
| 249 | * @var string | null |
||
| 250 | */ |
||
| 251 | protected $inheritanceType = null; |
||
| 252 | |||
| 253 | /** |
||
| 254 | * Discriminator column name |
||
| 255 | * |
||
| 256 | * @var string |
||
| 257 | */ |
||
| 258 | protected $discriminatorColumn = "type"; |
||
| 259 | |||
| 260 | /** |
||
| 261 | * Allow using a string to define which entity type should be instantiated. |
||
| 262 | * If not set, analogue will uses entity's FQDN |
||
| 263 | * |
||
| 264 | * @var array |
||
| 265 | */ |
||
| 266 | protected $discriminatorColumnMap = []; |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Return Domain class attributes, useful when mapping to a Plain PHP Object |
||
| 270 | * |
||
| 271 | * @return array |
||
| 272 | */ |
||
| 273 | public function getAttributes() |
||
| 277 | |||
| 278 | /** |
||
| 279 | * Set the domain class attributes |
||
| 280 | * |
||
| 281 | * @param array $attributeNames |
||
| 282 | */ |
||
| 283 | public function setAttributes(array $attributeNames) |
||
| 287 | |||
| 288 | /** |
||
| 289 | * Get all the attribute names for the class, including relationships, embeddables and primary key. |
||
| 290 | * |
||
| 291 | * @return array |
||
| 292 | */ |
||
| 293 | public function getCompiledAttributes() |
||
| 305 | |||
| 306 | /** |
||
| 307 | * Set the date format to use with the current database connection |
||
| 308 | * |
||
| 309 | * @param string $format |
||
| 310 | */ |
||
| 311 | public function setDateFormat($format) |
||
| 315 | |||
| 316 | /** |
||
| 317 | * Get the date format to use with the current database connection |
||
| 318 | * |
||
| 319 | * @return string |
||
| 320 | */ |
||
| 321 | public function getDateFormat() |
||
| 325 | |||
| 326 | /** |
||
| 327 | * Set the Driver for this mapping |
||
| 328 | * |
||
| 329 | * @param string $driver |
||
| 330 | */ |
||
| 331 | public function setDriver($driver) |
||
| 335 | |||
| 336 | /** |
||
| 337 | * Get the Driver for this mapping. |
||
| 338 | * |
||
| 339 | * @return string |
||
| 340 | */ |
||
| 341 | public function getDriver() |
||
| 345 | |||
| 346 | /** |
||
| 347 | * Set the db connection to use on the table |
||
| 348 | * |
||
| 349 | * @param $connection |
||
| 350 | */ |
||
| 351 | public function setConnection($connection) |
||
| 355 | |||
| 356 | /** |
||
| 357 | * Get the Database connection the Entity is stored on. |
||
| 358 | * |
||
| 359 | * @return string |
||
| 360 | */ |
||
| 361 | public function getConnection() |
||
| 365 | |||
| 366 | /** |
||
| 367 | * Get the table associated with the entity. |
||
| 368 | * |
||
| 369 | * @return string |
||
| 370 | */ |
||
| 371 | public function getTable() |
||
| 379 | |||
| 380 | /** |
||
| 381 | * Set the database table name |
||
| 382 | * |
||
| 383 | * @param string $table |
||
| 384 | */ |
||
| 385 | public function setTable($table) |
||
| 389 | |||
| 390 | /** |
||
| 391 | * Get the pgSql sequence name |
||
| 392 | * |
||
| 393 | * @return string |
||
| 394 | */ |
||
| 395 | public function getSequence() |
||
| 403 | |||
| 404 | /** |
||
| 405 | * Get the custom entity class |
||
| 406 | * |
||
| 407 | * @return string namespaced class name |
||
| 408 | */ |
||
| 409 | public function getClass() |
||
| 413 | |||
| 414 | /** |
||
| 415 | * Set the custom entity class |
||
| 416 | * |
||
| 417 | * @param string $class namespaced class name |
||
| 418 | */ |
||
| 419 | public function setClass($class) |
||
| 423 | |||
| 424 | /** |
||
| 425 | * Get the embedded Value Objects |
||
| 426 | * |
||
| 427 | * @return array |
||
| 428 | */ |
||
| 429 | public function getEmbeddables() |
||
| 433 | |||
| 434 | /** |
||
| 435 | * Set the embedded Value Objects |
||
| 436 | * |
||
| 437 | * @param array $embeddables |
||
| 438 | */ |
||
| 439 | public function setEmbeddables(array $embeddables) |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Get the relationships to map on a custom domain |
||
| 446 | * class. |
||
| 447 | * |
||
| 448 | * @return array |
||
| 449 | */ |
||
| 450 | public function getRelationships() |
||
| 454 | |||
| 455 | /** |
||
| 456 | * Get the relationships that will not have a proxy |
||
| 457 | * set on them |
||
| 458 | * |
||
| 459 | * @return array |
||
| 460 | */ |
||
| 461 | public function getRelationshipsWithoutProxy() |
||
| 465 | |||
| 466 | /** |
||
| 467 | * Relationships of the Entity type |
||
| 468 | * |
||
| 469 | * @return array |
||
| 470 | */ |
||
| 471 | public function getSingleRelationships() |
||
| 475 | |||
| 476 | /** |
||
| 477 | * Relationships of type Collection |
||
| 478 | * |
||
| 479 | * @return array |
||
| 480 | */ |
||
| 481 | public function getManyRelationships() |
||
| 485 | |||
| 486 | /** |
||
| 487 | * Relationships with foreign key in the mapped entity record. |
||
| 488 | * |
||
| 489 | * @return array |
||
| 490 | */ |
||
| 491 | public function getLocalRelationships() |
||
| 495 | |||
| 496 | /** |
||
| 497 | * Return the local keys associated to the relationship |
||
| 498 | * |
||
| 499 | * @param string $relation |
||
| 500 | * @return string | array | null |
||
| 501 | */ |
||
| 502 | public function getLocalKeys($relation) |
||
| 506 | |||
| 507 | /** |
||
| 508 | * Relationships with foreign key in the related Entity record |
||
| 509 | * |
||
| 510 | * @return array |
||
| 511 | */ |
||
| 512 | public function getForeignRelationships() |
||
| 516 | |||
| 517 | /** |
||
| 518 | * Relationships which keys are stored in a pivot record |
||
| 519 | * |
||
| 520 | * @return array |
||
| 521 | */ |
||
| 522 | public function getPivotRelationships() |
||
| 526 | |||
| 527 | /** |
||
| 528 | * Get the targetted type for a relationship. Return null if polymorphic |
||
| 529 | * |
||
| 530 | * @param string $relation |
||
| 531 | * @return string | null |
||
| 532 | */ |
||
| 533 | public function getTargettedClass($relation) |
||
| 537 | |||
| 538 | /** |
||
| 539 | * Add a Dynamic Relationship method at runtime. This has to be done |
||
| 540 | * by hooking the 'initializing' event, before entityMap is initialized. |
||
| 541 | * |
||
| 542 | * @param string $name Relation name |
||
| 543 | * @param \Closure $relationship |
||
| 544 | * |
||
| 545 | * @return void |
||
| 546 | */ |
||
| 547 | public function addRelationshipMethod($name, \Closure $relationship) |
||
| 551 | |||
| 552 | /** |
||
| 553 | * Get the dynamic relationship method names. |
||
| 554 | * |
||
| 555 | * @return array |
||
| 556 | */ |
||
| 557 | public function getDynamicRelationships() |
||
| 561 | |||
| 562 | /** |
||
| 563 | * Get the relationships that have to be eager loaded |
||
| 564 | * on each request. |
||
| 565 | * |
||
| 566 | * @return array |
||
| 567 | */ |
||
| 568 | public function getEagerloadedRelationships() |
||
| 572 | |||
| 573 | /** |
||
| 574 | * Get the primary key for the entity. |
||
| 575 | * |
||
| 576 | * @return string |
||
| 577 | */ |
||
| 578 | public function getKeyName() |
||
| 582 | |||
| 583 | /** |
||
| 584 | * Set the primary key for the entity. |
||
| 585 | * |
||
| 586 | * @param $key |
||
| 587 | * @return void |
||
| 588 | */ |
||
| 589 | public function setKeyName($key) |
||
| 593 | |||
| 594 | /** |
||
| 595 | * Get the table qualified key name. |
||
| 596 | * |
||
| 597 | * @return string |
||
| 598 | */ |
||
| 599 | public function getQualifiedKeyName() |
||
| 603 | |||
| 604 | /** |
||
| 605 | * Get the number of models to return per page. |
||
| 606 | * |
||
| 607 | * @return int |
||
| 608 | */ |
||
| 609 | public function getPerPage() |
||
| 613 | |||
| 614 | /** |
||
| 615 | * Set the number of models to return per page. |
||
| 616 | * |
||
| 617 | * @param int $perPage |
||
| 618 | * @return void |
||
| 619 | */ |
||
| 620 | public function setPerPage($perPage) |
||
| 624 | |||
| 625 | /** |
||
| 626 | * Determine if the entity uses get. |
||
| 627 | * |
||
| 628 | * @return bool |
||
| 629 | */ |
||
| 630 | public function usesTimestamps() |
||
| 634 | |||
| 635 | /** |
||
| 636 | * Determine if the entity uses soft deletes |
||
| 637 | * |
||
| 638 | * @return bool |
||
| 639 | */ |
||
| 640 | public function usesSoftDeletes() |
||
| 644 | |||
| 645 | /** |
||
| 646 | * Get the 'created_at' column name |
||
| 647 | * |
||
| 648 | * @return string |
||
| 649 | */ |
||
| 650 | public function getCreatedAtColumn() |
||
| 654 | |||
| 655 | /** |
||
| 656 | * Get the 'updated_at' column name |
||
| 657 | * |
||
| 658 | * @return string |
||
| 659 | */ |
||
| 660 | public function getUpdatedAtColumn() |
||
| 664 | |||
| 665 | /** |
||
| 666 | * Get the deleted_at column |
||
| 667 | * |
||
| 668 | * @return string |
||
| 669 | */ |
||
| 670 | public function getQualifiedDeletedAtColumn() |
||
| 674 | |||
| 675 | /** |
||
| 676 | * Get the default foreign key name for the model. |
||
| 677 | * |
||
| 678 | * @return string |
||
| 679 | */ |
||
| 680 | public function getForeignKey() |
||
| 684 | |||
| 685 | /** |
||
| 686 | * Return the inheritance type used by the entity. |
||
| 687 | * |
||
| 688 | * @return string|null |
||
| 689 | */ |
||
| 690 | public function getInheritanceType() |
||
| 694 | |||
| 695 | /** |
||
| 696 | * Return the discriminator column name on the entity that's |
||
| 697 | * used for table inheritance. |
||
| 698 | * |
||
| 699 | * @return string |
||
| 700 | */ |
||
| 701 | public function getDiscriminatorColumn() |
||
| 705 | |||
| 706 | /** |
||
| 707 | * Return the mapping of discriminator column values to |
||
| 708 | * entity class names that are used for table inheritance. |
||
| 709 | * |
||
| 710 | * @return array |
||
| 711 | */ |
||
| 712 | public function getDiscriminatorColumnMap() |
||
| 716 | |||
| 717 | /** |
||
| 718 | * Return true if the entity should be instanciated using |
||
| 719 | * the IoC Container |
||
| 720 | * |
||
| 721 | * @return boolean |
||
| 722 | */ |
||
| 723 | public function useDependencyInjection() |
||
| 727 | |||
| 728 | /** |
||
| 729 | * Define a one-to-one relationship. |
||
| 730 | * |
||
| 731 | * @param mixed $entity |
||
| 732 | * @param string $related entity class |
||
| 733 | * @param string $foreignKey |
||
| 734 | * @param string $localKey |
||
| 735 | * @throws MappingException |
||
| 736 | * @return \Analogue\ORM\Relationships\HasOne |
||
| 737 | */ |
||
| 738 | public function hasOne($entity, $related, $foreignKey = null, $localKey = null) |
||
| 764 | |||
| 765 | /** |
||
| 766 | * Define a polymorphic one-to-one relationship. |
||
| 767 | * |
||
| 768 | * @param mixed $entity |
||
| 769 | * @param string $related |
||
| 770 | * @param string $name |
||
| 771 | * @param string|null $type |
||
| 772 | * @param string|null $id |
||
| 773 | * @param string|null $localKey |
||
| 774 | * @throws MappingException |
||
| 775 | * @return \Analogue\ORM\Relationships\MorphOne |
||
| 776 | */ |
||
| 777 | public function morphOne($entity, $related, $name, $type = null, $id = null, $localKey = null) |
||
| 803 | |||
| 804 | /** |
||
| 805 | * Define an inverse one-to-one or many relationship. |
||
| 806 | * |
||
| 807 | * @param mixed $entity |
||
| 808 | * @param string $related |
||
| 809 | * @param string|null $foreignKey |
||
| 810 | * @param string|null $otherKey |
||
| 811 | * @param string|null $relation |
||
|
|
|||
| 812 | * @throws MappingException |
||
| 813 | * @return \Analogue\ORM\Relationships\BelongsTo |
||
| 814 | */ |
||
| 815 | public function belongsTo($entity, $related, $foreignKey = null, $otherKey = null) |
||
| 839 | |||
| 840 | /** |
||
| 841 | * Define a polymorphic, inverse one-to-one or many relationship. |
||
| 842 | * |
||
| 843 | * @param mixed $entity |
||
| 844 | * @param string|null $name |
||
| 845 | * @param string|null $type |
||
| 846 | * @param string|null $id |
||
| 847 | * @throws MappingException |
||
| 848 | * @return \Analogue\ORM\Relationships\MorphTo |
||
| 849 | */ |
||
| 850 | public function morphTo($entity, $name = null, $type = null, $id = null) |
||
| 904 | |||
| 905 | /** |
||
| 906 | * Define a one-to-many relationship. |
||
| 907 | * |
||
| 908 | * @param mixed $entity |
||
| 909 | * @param string $related |
||
| 910 | * @param string|null $foreignKey |
||
| 911 | * @param string|null $localKey |
||
| 912 | * @throws MappingException |
||
| 913 | * @return \Analogue\ORM\Relationships\HasMany |
||
| 914 | */ |
||
| 915 | public function hasMany($entity, $related, $foreignKey = null, $localKey = null) |
||
| 934 | |||
| 935 | /** |
||
| 936 | * Define a has-many-through relationship. |
||
| 937 | * |
||
| 938 | * @param mixed $entity |
||
| 939 | * @param string $related |
||
| 940 | * @param string $through |
||
| 941 | * @param string|null $firstKey |
||
| 942 | * @param string|null $secondKey |
||
| 943 | * @throws MappingException |
||
| 944 | * @return \Analogue\ORM\Relationships\HasManyThrough |
||
| 945 | */ |
||
| 946 | public function hasManyThrough($entity, $related, $through, $firstKey = null, $secondKey = null) |
||
| 968 | |||
| 969 | /** |
||
| 970 | * Define a polymorphic one-to-many relationship. |
||
| 971 | * |
||
| 972 | * @param mixed $entity |
||
| 973 | * @param string $related |
||
| 974 | * @param string $name |
||
| 975 | * @param string|null $type |
||
| 976 | * @param string|null $id |
||
| 977 | * @param string|null $localKey |
||
| 978 | * @return \Analogue\ORM\Relationships\MorphMany |
||
| 979 | */ |
||
| 980 | public function morphMany($entity, $related, $name, $type = null, $id = null, $localKey = null) |
||
| 1002 | |||
| 1003 | /** |
||
| 1004 | * Define a many-to-many relationship. |
||
| 1005 | * |
||
| 1006 | * @param mixed $entity |
||
| 1007 | * @param string $relatedClass |
||
| 1008 | * @param string|null $table |
||
| 1009 | * @param string|null $foreignKey |
||
| 1010 | * @param string|null $otherKey |
||
| 1011 | * @param string|null $relation |
||
| 1012 | * @throws MappingException |
||
| 1013 | * @return \Analogue\ORM\Relationships\BelongsToMany |
||
| 1014 | */ |
||
| 1015 | public function belongsToMany($entity, $related, $table = null, $foreignKey = null, $otherKey = null) |
||
| 1045 | |||
| 1046 | /** |
||
| 1047 | * Define a polymorphic many-to-many relationship. |
||
| 1048 | * |
||
| 1049 | * @param mixed $entity |
||
| 1050 | * @param string $related |
||
| 1051 | * @param string $name |
||
| 1052 | * @param string|null $table |
||
| 1053 | * @param string|null $foreignKey |
||
| 1054 | * @param string|null $otherKey |
||
| 1055 | * @param bool $inverse |
||
| 1056 | * @throws MappingException |
||
| 1057 | * @return \Analogue\ORM\Relationships\MorphToMany |
||
| 1058 | */ |
||
| 1059 | public function morphToMany($entity, $related, $name, $table = null, $foreignKey = null, $otherKey = null, $inverse = false) |
||
| 1082 | |||
| 1083 | /** |
||
| 1084 | * Define a polymorphic, inverse many-to-many relationship. |
||
| 1085 | * |
||
| 1086 | * @param mixed $entity |
||
| 1087 | * @param string $related |
||
| 1088 | * @param string $name |
||
| 1089 | * @param string|null $table |
||
| 1090 | * @param string|null $foreignKey |
||
| 1091 | * @param string|null $otherKey |
||
| 1092 | * @throws MappingException |
||
| 1093 | * @return \Analogue\ORM\Relationships\MorphToMany |
||
| 1094 | */ |
||
| 1095 | public function morphedByMany($entity, $related, $name, $table = null, $foreignKey = null, $otherKey = null) |
||
| 1113 | |||
| 1114 | /** |
||
| 1115 | * Get the joining table name for a many-to-many relation. |
||
| 1116 | * |
||
| 1117 | * @param EntityMap $relatedMap |
||
| 1118 | * @return string |
||
| 1119 | */ |
||
| 1120 | public function joiningTable($relatedMap) |
||
| 1138 | |||
| 1139 | /** |
||
| 1140 | * Get the polymorphic relationship columns. |
||
| 1141 | * |
||
| 1142 | * @param string $name |
||
| 1143 | * @param string $type |
||
| 1144 | * @param string $id |
||
| 1145 | * @return string[] |
||
| 1146 | */ |
||
| 1147 | protected function getMorphs($name, $type, $id) |
||
| 1155 | |||
| 1156 | /** |
||
| 1157 | * Get the class name for polymorphic relations. |
||
| 1158 | * |
||
| 1159 | * @return string |
||
| 1160 | */ |
||
| 1161 | public function getMorphClass() |
||
| 1166 | |||
| 1167 | /** |
||
| 1168 | * Create a new Entity Collection instance. |
||
| 1169 | * |
||
| 1170 | * @param array $entities |
||
| 1171 | * @return \Analogue\ORM\EntityCollection |
||
| 1172 | */ |
||
| 1173 | public function newCollection(array $entities = []) |
||
| 1178 | |||
| 1179 | /** |
||
| 1180 | * Process EntityMap parsing at initialization time |
||
| 1181 | * |
||
| 1182 | * @return void |
||
| 1183 | */ |
||
| 1184 | public function initialize() |
||
| 1198 | |||
| 1199 | /** |
||
| 1200 | * Parse every relationships on the EntityMap and sort |
||
| 1201 | * them by type. |
||
| 1202 | * |
||
| 1203 | * @return void |
||
| 1204 | */ |
||
| 1205 | public function boot() |
||
| 1211 | |||
| 1212 | /** |
||
| 1213 | * Get Methods that has been added in the child class. |
||
| 1214 | * |
||
| 1215 | * @return array |
||
| 1216 | */ |
||
| 1217 | protected function getCustomMethods() |
||
| 1225 | |||
| 1226 | /** |
||
| 1227 | * Parse user's class methods for relationships |
||
| 1228 | * |
||
| 1229 | * @param array $customMethods |
||
| 1230 | * @return array |
||
| 1231 | */ |
||
| 1232 | protected function parseMethodsForRelationship(array $customMethods) |
||
| 1257 | |||
| 1258 | /** |
||
| 1259 | * Sort Relationships methods by type |
||
| 1260 | * |
||
| 1261 | * TODO : replace this by direclty setting these value |
||
| 1262 | * in the corresponding methods, so we won't need |
||
| 1263 | * the correpondancy tabble |
||
| 1264 | * |
||
| 1265 | * @return void |
||
| 1266 | */ |
||
| 1267 | protected function sortRelationshipsByType() |
||
| 1278 | |||
| 1279 | /** |
||
| 1280 | * Override this method for custom entity instantiation |
||
| 1281 | * |
||
| 1282 | * @return null |
||
| 1283 | */ |
||
| 1284 | public function activator() |
||
| 1288 | |||
| 1289 | /** |
||
| 1290 | * Call dynamic relationship, if it exists |
||
| 1291 | * |
||
| 1292 | * @param string $method |
||
| 1293 | * @param array $parameters |
||
| 1294 | * @throws Exception |
||
| 1295 | * @return mixed |
||
| 1296 | */ |
||
| 1297 | public function __call($method, $parameters) |
||
| 1308 | } |
||
| 1309 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.