Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
parents.php
1<?php
2
4
6
12final class Parents extends Collection
13{
15 protected $items = [];
17 protected $descendant;
18
22 public function getDescendant(): ?Location
23 {
24 return $this->descendant;
25 }
26
31 public function setDescendant(Location $descendant): self
32 {
33 $this->descendant = $descendant;
34 return $this;
35 }
36
43 public function isContain(Location $location): bool
44 {
45 foreach($this->items as $item)
46 {
47 if($item->isEqualTo($location))
48 {
49 return true;
50 }
51 }
52
53 return false;
54 }
55
62 public function isEqualTo(Parents $parents): bool
63 {
64 if($this->count() !== $parents->count())
65 {
66 return false;
67 }
68
73 foreach($this as $idx => $item)
74 {
75 if(!$item->isEqualTo($parents[$idx]))
76 {
77 return false;
78 }
79 }
80
81 return true;
82 }
83
90 public function getItemByType(int $type):? Location
91 {
92 foreach($this->items as $item)
93 {
94 if($item->getType() === $type)
95 {
96 return $item;
97 }
98 }
99
100 return null;
101 }
102}
setDescendant(Location $descendant)
Definition parents.php:31