Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
remindcomparemanager.php
1<?php
2
4
9
11{
23 protected $diff;
27 protected $isEqual = true;
28
34 {
35 $this->currentCollection = $currentCollection;
36 $this->originalCollection = $originalCollection;
37
38 $this->compare();
39 }
40
53
57 protected function compare(): void
58 {
59 $this->diff = array_udiff(
60 $this->currentCollection->getCollection(),
61 $this->originalCollection->getCollection(),
62 [$this, 'compareHandler']
63 );
64
65 if (
66 $this->diff
67 || $this->originalCollection->count() !== $this->currentCollection->count()
68 )
69 {
70 $this->isEqual = false;
71 }
72 }
73
77 public function getDiff(): array
78 {
79 return $this->diff;
80 }
81
85 public function hasDiff(): bool
86 {
87 return (bool)$this->diff;
88 }
89
94 {
95 return new RemindCollection($this->diff);
96 }
97
101 public function isEqual(): bool
102 {
103 return $this->isEqual;
104 }
105
112 private function compareHandler(Remind $current, Remind $original): int
113 {
114 return $current->getSpecificTime()->getTimestamp() <=> $original->getSpecificTime()->getTimestamp();
115 }
116}
__construct(RemindCollection $currentCollection, RemindCollection $originalCollection)
static createInstance(RemindCollection $currentCollection, RemindCollection $originalCollection)