Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
collection.php
1<?php
2namespace Bitrix\Perfmon\Sql;
3
10{
12 private $list = [];
13
21 public function add(BaseObject $object)
22 {
23 $this->list[] = $object;
24 }
25
34 public function set($index, BaseObject $object)
35 {
36 $this->list[$index] = $object;
37 }
38
46 public function search($name)
47 {
49 foreach ($this->list as $object)
50 {
51 if ($object->compareName($name) == 0)
52 {
53 return $object;
54 }
55 }
56 return null;
57 }
58
66 public function searchIndex($name)
67 {
69 foreach ($this->list as $i => $object)
70 {
71 if ($object->compareName($name) == 0)
72 {
73 return $i;
74 }
75 }
76 return null;
77 }
78
84 public function getList()
85 {
86 return $this->list;
87 }
88
102 public function compare(Collection $targetList, $compareBody = true)
103 {
104 $difference = [];
106 foreach ($this->list as $source)
107 {
108 if (!$targetList->search($source->name))
109 {
110 $difference[] = [
111 $source,
112 null,
113 ];
114 }
115 }
117 foreach ($targetList->list as $target)
118 {
119 $source = $this->search($target->name);
120 if (!$source)
121 {
122 $difference[] = [
123 null,
124 $target,
125 ];
126 }
127 elseif (
128 !$compareBody
129 || $source->body !== $target->body
130 )
131 {
132 $difference[] = [
133 $source,
134 $target,
135 ];
136 }
137 }
138 return $difference;
139 }
140}
add(BaseObject $object)