Complex classes like NodeTrait 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 NodeTrait, and based on these observations, apply Extract Interface, too.
| 1 | <?php namespace Arcanedev\LaravelNestedSet; |
||
| 47 | trait NodeTrait |
||
| 48 | { |
||
| 49 | /* ------------------------------------------------------------------------------------------------ |
||
| 50 | | Traits |
||
| 51 | | ------------------------------------------------------------------------------------------------ |
||
| 52 | */ |
||
| 53 | use EloquentTrait, SoftDeleteTrait; |
||
| 54 | |||
| 55 | /* ------------------------------------------------------------------------------------------------ |
||
| 56 | | Properties |
||
| 57 | | ------------------------------------------------------------------------------------------------ |
||
| 58 | */ |
||
| 59 | /** |
||
| 60 | * Pending operation. |
||
| 61 | * |
||
| 62 | * @var array|null |
||
| 63 | */ |
||
| 64 | protected $pending; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Whether the node has moved since last save. |
||
| 68 | * |
||
| 69 | * @var bool |
||
| 70 | */ |
||
| 71 | protected $moved = false; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Keep track of the number of performed operations. |
||
| 75 | * |
||
| 76 | * @var int |
||
| 77 | */ |
||
| 78 | public static $actionsPerformed = 0; |
||
| 79 | |||
| 80 | /* ------------------------------------------------------------------------------------------------ |
||
| 81 | | Boot Function |
||
| 82 | | ------------------------------------------------------------------------------------------------ |
||
| 83 | */ |
||
| 84 | /** |
||
| 85 | * Sign on model events. |
||
| 86 | */ |
||
| 87 | 216 | public static function bootNodeTrait() |
|
| 111 | |||
| 112 | /* ------------------------------------------------------------------------------------------------ |
||
| 113 | | Relationships |
||
| 114 | | ------------------------------------------------------------------------------------------------ |
||
| 115 | */ |
||
| 116 | /** |
||
| 117 | * Relation to the parent. |
||
| 118 | * |
||
| 119 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
| 120 | */ |
||
| 121 | 12 | public function parent() |
|
| 126 | |||
| 127 | /** |
||
| 128 | * Relation to children. |
||
| 129 | * |
||
| 130 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
| 131 | */ |
||
| 132 | 12 | public function children() |
|
| 137 | |||
| 138 | /** |
||
| 139 | * Get query for descendants of the node. |
||
| 140 | * |
||
| 141 | * @return \Arcanedev\LaravelNestedSet\Eloquent\DescendantsRelation |
||
| 142 | */ |
||
| 143 | 36 | public function descendants() |
|
| 147 | |||
| 148 | /** |
||
| 149 | * Get query for siblings of the node. |
||
| 150 | * |
||
| 151 | * @return \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder |
||
| 152 | */ |
||
| 153 | 6 | public function siblings() |
|
| 159 | |||
| 160 | /** |
||
| 161 | * Get query for the node siblings and the node itself. |
||
| 162 | * |
||
| 163 | * @return \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder |
||
| 164 | */ |
||
| 165 | public function siblingsAndSelf() |
||
| 170 | |||
| 171 | /** |
||
| 172 | * Get the node siblings and the node itself. |
||
| 173 | * |
||
| 174 | * @param array $columns |
||
| 175 | * |
||
| 176 | * @return \Illuminate\Database\Eloquent\Collection |
||
| 177 | */ |
||
| 178 | public function getSiblingsAndSelf(array $columns = ['*']) |
||
| 182 | |||
| 183 | /* ------------------------------------------------------------------------------------------------ |
||
| 184 | | Getters & Setters |
||
| 185 | | ------------------------------------------------------------------------------------------------ |
||
| 186 | */ |
||
| 187 | /** |
||
| 188 | * Get the lft key name. |
||
| 189 | * |
||
| 190 | * @return string |
||
| 191 | */ |
||
| 192 | 195 | public function getLftName() |
|
| 196 | |||
| 197 | /** |
||
| 198 | * Get the rgt key name. |
||
| 199 | * |
||
| 200 | * @return string |
||
| 201 | */ |
||
| 202 | 168 | public function getRgtName() |
|
| 206 | |||
| 207 | /** |
||
| 208 | * Get the parent id key name. |
||
| 209 | * |
||
| 210 | * @return string |
||
| 211 | */ |
||
| 212 | 129 | public function getParentIdName() |
|
| 216 | |||
| 217 | /** |
||
| 218 | * Get the value of the model's lft key. |
||
| 219 | * |
||
| 220 | * @return int |
||
| 221 | */ |
||
| 222 | 144 | public function getLft() |
|
| 226 | |||
| 227 | /** |
||
| 228 | * Set the value of the model's lft key. |
||
| 229 | * |
||
| 230 | * @param int $value |
||
| 231 | * |
||
| 232 | * @return self |
||
| 233 | */ |
||
| 234 | 45 | public function setLft($value) |
|
| 240 | |||
| 241 | /** |
||
| 242 | * Get the value of the model's rgt key. |
||
| 243 | * |
||
| 244 | * @return int |
||
| 245 | */ |
||
| 246 | 96 | public function getRgt() |
|
| 250 | |||
| 251 | /** |
||
| 252 | * Set the value of the model's rgt key. |
||
| 253 | * |
||
| 254 | * @param int $value |
||
| 255 | * |
||
| 256 | * @return self |
||
| 257 | */ |
||
| 258 | 45 | public function setRgt($value) |
|
| 264 | |||
| 265 | /** |
||
| 266 | * Get the value of the model's parent id key. |
||
| 267 | * |
||
| 268 | * @return int |
||
| 269 | */ |
||
| 270 | 78 | public function getParentId() |
|
| 274 | |||
| 275 | /** |
||
| 276 | * Set the value of the model's parent id key. |
||
| 277 | * |
||
| 278 | * @param int $value |
||
| 279 | * |
||
| 280 | * @return self |
||
| 281 | */ |
||
| 282 | 51 | public function setParentId($value) |
|
| 288 | |||
| 289 | /** |
||
| 290 | * Apply parent model. |
||
| 291 | * |
||
| 292 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable|null $value |
||
| 293 | * |
||
| 294 | * @return self |
||
| 295 | */ |
||
| 296 | 42 | protected function setParent($value) |
|
| 303 | |||
| 304 | /** |
||
| 305 | * Set the value of model's parent id key. |
||
| 306 | * |
||
| 307 | * Behind the scenes node is appended to found parent node. |
||
| 308 | * |
||
| 309 | * @param int $value |
||
| 310 | * |
||
| 311 | * @throws \Exception If parent node doesn't exists |
||
| 312 | */ |
||
| 313 | 9 | public function setParentIdAttribute($value) |
|
| 326 | |||
| 327 | /** |
||
| 328 | * Get the boundaries. |
||
| 329 | * |
||
| 330 | * @return array |
||
| 331 | */ |
||
| 332 | 36 | public function getBounds() |
|
| 336 | |||
| 337 | /** |
||
| 338 | * Get the scope attributes. |
||
| 339 | * |
||
| 340 | * @return array |
||
| 341 | */ |
||
| 342 | 123 | protected function getScopeAttributes() |
|
| 346 | |||
| 347 | /** |
||
| 348 | * Set the lft and rgt boundaries to null. |
||
| 349 | * |
||
| 350 | * @return self |
||
| 351 | */ |
||
| 352 | 51 | protected function dirtyBounds() |
|
| 359 | |||
| 360 | /** |
||
| 361 | * Returns node that is next to current node without constraining to siblings. |
||
| 362 | * This can be either a next sibling or a next sibling of the parent node. |
||
| 363 | * |
||
| 364 | * @param array $columns |
||
| 365 | * |
||
| 366 | * @return self |
||
| 367 | */ |
||
| 368 | public function getNextNode(array $columns = ['*']) |
||
| 372 | |||
| 373 | /** |
||
| 374 | * Returns node that is before current node without constraining to siblings. |
||
| 375 | * This can be either a prev sibling or parent node. |
||
| 376 | * |
||
| 377 | * @param array $columns |
||
| 378 | * |
||
| 379 | * @return self |
||
| 380 | */ |
||
| 381 | 3 | public function getPrevNode(array $columns = ['*']) |
|
| 385 | |||
| 386 | /** |
||
| 387 | * Get the ancestors nodes. |
||
| 388 | * |
||
| 389 | * @param array $columns |
||
| 390 | * |
||
| 391 | * @return \Arcanedev\LaravelNestedSet\Eloquent\Collection |
||
| 392 | */ |
||
| 393 | 6 | public function getAncestors(array $columns = ['*']) |
|
| 399 | |||
| 400 | /** |
||
| 401 | * Get the descendants nodes. |
||
| 402 | * |
||
| 403 | * @param array $columns |
||
| 404 | * |
||
| 405 | * @return \Arcanedev\LaravelNestedSet\Eloquent\Collection |
||
| 406 | */ |
||
| 407 | 9 | public function getDescendants(array $columns = ['*']) |
|
| 411 | |||
| 412 | /** |
||
| 413 | * Get the siblings nodes. |
||
| 414 | * |
||
| 415 | * @param array $columns |
||
| 416 | * |
||
| 417 | * @return \Arcanedev\LaravelNestedSet\Eloquent\Collection |
||
| 418 | */ |
||
| 419 | 6 | public function getSiblings(array $columns = ['*']) |
|
| 423 | |||
| 424 | /** |
||
| 425 | * Get the next siblings nodes. |
||
| 426 | * |
||
| 427 | * @param array $columns |
||
| 428 | * |
||
| 429 | * @return \Arcanedev\LaravelNestedSet\Eloquent\Collection |
||
| 430 | */ |
||
| 431 | 6 | public function getNextSiblings(array $columns = ['*']) |
|
| 435 | |||
| 436 | /** |
||
| 437 | * Get the previous siblings nodes. |
||
| 438 | * |
||
| 439 | * @param array $columns |
||
| 440 | * |
||
| 441 | * @return \Arcanedev\LaravelNestedSet\Eloquent\Collection |
||
| 442 | */ |
||
| 443 | 6 | public function getPrevSiblings(array $columns = ['*']) |
|
| 447 | |||
| 448 | /** |
||
| 449 | * Get the next sibling node. |
||
| 450 | * |
||
| 451 | * @param array $columns |
||
| 452 | * |
||
| 453 | * @return self |
||
| 454 | */ |
||
| 455 | 3 | public function getNextSibling(array $columns = ['*']) |
|
| 459 | |||
| 460 | /** |
||
| 461 | * Get the previous sibling node. |
||
| 462 | * |
||
| 463 | * @param array $columns |
||
| 464 | * |
||
| 465 | * @return self |
||
| 466 | */ |
||
| 467 | 3 | public function getPrevSibling(array $columns = ['*']) |
|
| 471 | |||
| 472 | /** |
||
| 473 | * Get node height (rgt - lft + 1). |
||
| 474 | * |
||
| 475 | * @return int |
||
| 476 | */ |
||
| 477 | 27 | public function getNodeHeight() |
|
| 483 | |||
| 484 | /** |
||
| 485 | * Get number of descendant nodes. |
||
| 486 | * |
||
| 487 | * @return int |
||
| 488 | */ |
||
| 489 | 3 | public function getDescendantCount() |
|
| 493 | |||
| 494 | /** |
||
| 495 | * Set raw node. |
||
| 496 | * |
||
| 497 | * @param int $lft |
||
| 498 | * @param int $rgt |
||
| 499 | * @param int $parentId |
||
| 500 | * |
||
| 501 | * @return self |
||
| 502 | */ |
||
| 503 | 9 | public function rawNode($lft, $rgt, $parentId) |
|
| 509 | |||
| 510 | /** |
||
| 511 | * Set an action. |
||
| 512 | * |
||
| 513 | * @param string $action |
||
| 514 | * |
||
| 515 | * @return self |
||
| 516 | */ |
||
| 517 | 90 | protected function setNodeAction($action) |
|
| 524 | |||
| 525 | /* ------------------------------------------------------------------------------------------------ |
||
| 526 | | Other Functions |
||
| 527 | | ------------------------------------------------------------------------------------------------ |
||
| 528 | */ |
||
| 529 | /** |
||
| 530 | * Get the lower bound. |
||
| 531 | * |
||
| 532 | * @return int |
||
| 533 | */ |
||
| 534 | 24 | protected function getLowerBound() |
|
| 538 | |||
| 539 | /** |
||
| 540 | * Call pending action. |
||
| 541 | */ |
||
| 542 | 75 | protected function callPendingAction() |
|
| 558 | |||
| 559 | /** |
||
| 560 | * @return bool |
||
| 561 | */ |
||
| 562 | 9 | protected function actionRaw() |
|
| 566 | |||
| 567 | /** |
||
| 568 | * Make a root node. |
||
| 569 | */ |
||
| 570 | 24 | protected function actionRoot() |
|
| 590 | |||
| 591 | /** |
||
| 592 | * Append or prepend a node to the parent. |
||
| 593 | * |
||
| 594 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $parent |
||
| 595 | * @param bool $prepend |
||
| 596 | * |
||
| 597 | * @return bool |
||
| 598 | */ |
||
| 599 | 24 | protected function actionAppendOrPrepend(Nodeable $parent, $prepend = false) |
|
| 613 | |||
| 614 | /** |
||
| 615 | * Insert node before or after another node. |
||
| 616 | * |
||
| 617 | * @param self $node |
||
| 618 | * @param bool $after |
||
| 619 | * |
||
| 620 | * @return bool |
||
| 621 | */ |
||
| 622 | 21 | protected function actionBeforeOrAfter(self $node, $after = false) |
|
| 628 | |||
| 629 | /** |
||
| 630 | * Refresh node's crucial attributes. |
||
| 631 | */ |
||
| 632 | 66 | public function refreshNode() |
|
| 640 | |||
| 641 | /** |
||
| 642 | * Get query for siblings after the node. |
||
| 643 | * |
||
| 644 | * @return \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder |
||
| 645 | */ |
||
| 646 | 18 | public function nextSiblings() |
|
| 651 | |||
| 652 | /** |
||
| 653 | * Get query for siblings before the node. |
||
| 654 | * |
||
| 655 | * @return \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder |
||
| 656 | */ |
||
| 657 | 12 | public function prevSiblings() |
|
| 662 | |||
| 663 | /** |
||
| 664 | * Get query for nodes after current node. |
||
| 665 | * |
||
| 666 | * @return \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder |
||
| 667 | */ |
||
| 668 | 21 | public function nextNodes() |
|
| 673 | |||
| 674 | /** |
||
| 675 | * Get query for nodes before current node in reversed order. |
||
| 676 | * |
||
| 677 | * @return \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder |
||
| 678 | */ |
||
| 679 | 15 | public function prevNodes() |
|
| 684 | |||
| 685 | /** |
||
| 686 | * Get query for ancestors to the node not including the node itself. |
||
| 687 | * |
||
| 688 | * @return \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder |
||
| 689 | */ |
||
| 690 | 3 | public function ancestors() |
|
| 695 | |||
| 696 | /** |
||
| 697 | * Make this node a root node. |
||
| 698 | * |
||
| 699 | * @return self |
||
| 700 | */ |
||
| 701 | 36 | public function makeRoot() |
|
| 705 | |||
| 706 | /** |
||
| 707 | * Save node as root. |
||
| 708 | * |
||
| 709 | * @return bool |
||
| 710 | */ |
||
| 711 | 6 | public function saveAsRoot() |
|
| 719 | |||
| 720 | /** |
||
| 721 | * Append and save a node. |
||
| 722 | * |
||
| 723 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 724 | * |
||
| 725 | * @return bool |
||
| 726 | */ |
||
| 727 | 12 | public function appendNode(Nodeable $node) |
|
| 731 | |||
| 732 | /** |
||
| 733 | * Prepend and save a node. |
||
| 734 | * |
||
| 735 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 736 | * |
||
| 737 | * @return bool |
||
| 738 | */ |
||
| 739 | 3 | public function prependNode(Nodeable $node) |
|
| 743 | |||
| 744 | /** |
||
| 745 | * Append a node to the new parent. |
||
| 746 | * |
||
| 747 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $parent |
||
| 748 | * |
||
| 749 | * @return self |
||
| 750 | */ |
||
| 751 | 33 | public function appendToNode(Nodeable $parent) |
|
| 755 | |||
| 756 | /** |
||
| 757 | * Prepend a node to the new parent. |
||
| 758 | * |
||
| 759 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $parent |
||
| 760 | * |
||
| 761 | * @return \Arcanedev\LaravelNestedSet\Contracts\Nodeable |
||
| 762 | */ |
||
| 763 | 6 | public function prependToNode(Nodeable $parent) |
|
| 767 | |||
| 768 | /** |
||
| 769 | * Append or prepend a node to parent. |
||
| 770 | * |
||
| 771 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $parent |
||
| 772 | * @param bool $prepend |
||
| 773 | * |
||
| 774 | * @return \Arcanedev\LaravelNestedSet\Contracts\Nodeable |
||
| 775 | */ |
||
| 776 | 39 | public function appendOrPrependTo(Nodeable $parent, $prepend = false) |
|
| 785 | |||
| 786 | /** |
||
| 787 | * Insert self after a node. |
||
| 788 | * |
||
| 789 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 790 | * |
||
| 791 | * @return \Arcanedev\LaravelNestedSet\Contracts\Nodeable |
||
| 792 | */ |
||
| 793 | 21 | public function afterNode(Nodeable $node) |
|
| 797 | |||
| 798 | /** |
||
| 799 | * Insert self before node. |
||
| 800 | * |
||
| 801 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 802 | * |
||
| 803 | * @return \Arcanedev\LaravelNestedSet\Contracts\Nodeable |
||
| 804 | */ |
||
| 805 | 6 | public function beforeNode(Nodeable $node) |
|
| 806 | { |
||
| 807 | 6 | return $this->beforeOrAfterNode($node); |
|
| 808 | } |
||
| 809 | |||
| 810 | /** |
||
| 811 | * Set before or after a node. |
||
| 812 | * |
||
| 813 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 814 | * @param bool $after |
||
| 815 | * |
||
| 816 | * @return \Arcanedev\LaravelNestedSet\Contracts\Nodeable |
||
| 817 | */ |
||
| 818 | 27 | public function beforeOrAfterNode(Nodeable $node, $after = false) |
|
| 830 | |||
| 831 | /** |
||
| 832 | * Insert after a node and save. |
||
| 833 | * |
||
| 834 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 835 | * |
||
| 836 | * @return bool |
||
| 837 | */ |
||
| 838 | 12 | public function insertAfterNode(Nodeable $node) |
|
| 842 | |||
| 843 | /** |
||
| 844 | * Insert self before a node and save. |
||
| 845 | * |
||
| 846 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 847 | * |
||
| 848 | * @return bool |
||
| 849 | */ |
||
| 850 | 3 | public function insertBeforeNode(Nodeable $node) |
|
| 859 | |||
| 860 | /** |
||
| 861 | * Move node up given amount of positions. |
||
| 862 | * |
||
| 863 | * @param int $amount |
||
| 864 | * |
||
| 865 | * @return bool |
||
| 866 | */ |
||
| 867 | 3 | public function up($amount = 1) |
|
| 878 | |||
| 879 | /** |
||
| 880 | * Move node down given amount of positions. |
||
| 881 | * |
||
| 882 | * @param int $amount |
||
| 883 | * |
||
| 884 | * @return bool |
||
| 885 | */ |
||
| 886 | 12 | public function down($amount = 1) |
|
| 897 | |||
| 898 | /** |
||
| 899 | * Insert node at specific position. |
||
| 900 | * |
||
| 901 | * @param int $position |
||
| 902 | * |
||
| 903 | * @return bool |
||
| 904 | */ |
||
| 905 | 51 | protected function insertAt($position) |
|
| 915 | |||
| 916 | /** |
||
| 917 | * Move a node to the new position. |
||
| 918 | * |
||
| 919 | * @param int $position |
||
| 920 | * |
||
| 921 | * @return int |
||
| 922 | */ |
||
| 923 | 30 | protected function moveNode($position) |
|
| 932 | |||
| 933 | /** |
||
| 934 | * Insert new node at specified position. |
||
| 935 | * |
||
| 936 | * @param int $position |
||
| 937 | * |
||
| 938 | * @return bool |
||
| 939 | */ |
||
| 940 | 24 | protected function insertNode($position) |
|
| 951 | |||
| 952 | /** |
||
| 953 | * Update the tree when the node is removed physically. |
||
| 954 | */ |
||
| 955 | 15 | protected function deleteDescendants() |
|
| 977 | |||
| 978 | /** |
||
| 979 | * Restore the descendants. |
||
| 980 | * |
||
| 981 | * @param \Carbon\Carbon $deletedAt |
||
| 982 | */ |
||
| 983 | 3 | protected function restoreDescendants($deletedAt) |
|
| 990 | |||
| 991 | /** |
||
| 992 | * Get a new base query that includes deleted nodes. |
||
| 993 | * |
||
| 994 | * @param string|null $table |
||
| 995 | * |
||
| 996 | * @return \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder |
||
| 997 | */ |
||
| 998 | 90 | public function newNestedSetQuery($table = null) |
|
| 1006 | |||
| 1007 | /** |
||
| 1008 | * Create a new scoped query. |
||
| 1009 | * |
||
| 1010 | * @param string|null $table |
||
| 1011 | * |
||
| 1012 | * @return \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder |
||
| 1013 | */ |
||
| 1014 | 105 | public function newScopedQuery($table = null) |
|
| 1018 | |||
| 1019 | /** |
||
| 1020 | * Apply the nested set scope. |
||
| 1021 | * |
||
| 1022 | * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query |
||
| 1023 | * @param string $table |
||
| 1024 | * |
||
| 1025 | * @return \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder|\Illuminate\Database\Query\Builder |
||
| 1026 | */ |
||
| 1027 | 156 | public function applyNestedSetScope($query, $table = null) |
|
| 1043 | |||
| 1044 | /** |
||
| 1045 | * @param array $attributes |
||
| 1046 | * |
||
| 1047 | * @return self |
||
| 1048 | */ |
||
| 1049 | 9 | public static function scoped(array $attributes) |
|
| 1057 | |||
| 1058 | /** |
||
| 1059 | * Save a new model and return the instance. |
||
| 1060 | * |
||
| 1061 | * Use `children` key on `$attributes` to create child nodes. |
||
| 1062 | * |
||
| 1063 | * @param array $attributes |
||
| 1064 | * @param self $parent |
||
| 1065 | * |
||
| 1066 | * @return self |
||
| 1067 | */ |
||
| 1068 | 9 | public static function create(array $attributes = [], self $parent = null) |
|
| 1090 | |||
| 1091 | /* ------------------------------------------------------------------------------------------------ |
||
| 1092 | | Check Functions |
||
| 1093 | | ------------------------------------------------------------------------------------------------ |
||
| 1094 | */ |
||
| 1095 | /** |
||
| 1096 | * Get whether node is root. |
||
| 1097 | * |
||
| 1098 | * @return bool |
||
| 1099 | */ |
||
| 1100 | 12 | public function isRoot() |
|
| 1104 | |||
| 1105 | /** |
||
| 1106 | * Get whether a node is a descendant of other node. |
||
| 1107 | * |
||
| 1108 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 1109 | * |
||
| 1110 | * @return bool |
||
| 1111 | */ |
||
| 1112 | 57 | public function isDescendantOf(Nodeable $node) |
|
| 1119 | |||
| 1120 | /** |
||
| 1121 | * Get whether the node is immediate children of other node. |
||
| 1122 | * |
||
| 1123 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 1124 | * |
||
| 1125 | * @return bool |
||
| 1126 | */ |
||
| 1127 | 3 | public function isChildOf(Nodeable $node) |
|
| 1131 | |||
| 1132 | /** |
||
| 1133 | * Get whether the node is a sibling of another node. |
||
| 1134 | * |
||
| 1135 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 1136 | * |
||
| 1137 | * @return bool |
||
| 1138 | */ |
||
| 1139 | 24 | public function isSiblingOf(Nodeable $node) |
|
| 1143 | |||
| 1144 | /** |
||
| 1145 | * Get whether the node is an ancestor of other node, including immediate parent. |
||
| 1146 | * |
||
| 1147 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 1148 | * |
||
| 1149 | * @return bool |
||
| 1150 | */ |
||
| 1151 | 3 | public function isAncestorOf(Nodeable $node) |
|
| 1156 | |||
| 1157 | /** |
||
| 1158 | * Get whether the node has moved since last save. |
||
| 1159 | * |
||
| 1160 | * @return bool |
||
| 1161 | */ |
||
| 1162 | 18 | public function hasMoved() |
|
| 1166 | |||
| 1167 | /* ------------------------------------------------------------------------------------------------ |
||
| 1168 | | Assertion Functions |
||
| 1169 | | ------------------------------------------------------------------------------------------------ |
||
| 1170 | */ |
||
| 1171 | /** |
||
| 1172 | * Assert that the node is not a descendant. |
||
| 1173 | * |
||
| 1174 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 1175 | * |
||
| 1176 | * @return self |
||
| 1177 | * |
||
| 1178 | * @throws \LogicException |
||
| 1179 | */ |
||
| 1180 | 60 | protected function assertNotDescendant(Nodeable $node) |
|
| 1189 | |||
| 1190 | /** |
||
| 1191 | * Assert node exists. |
||
| 1192 | * |
||
| 1193 | * @param \Arcanedev\LaravelNestedSet\Contracts\Nodeable $node |
||
| 1194 | * |
||
| 1195 | * @return self |
||
| 1196 | * |
||
| 1197 | * @throws \LogicException |
||
| 1198 | */ |
||
| 1199 | 63 | protected function assertNodeExists(Nodeable $node) |
|
| 1207 | } |
||
| 1208 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.