Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
excludeddatecomparemanager.php
1<?php
2
4
8
10{
22 protected $isEqual = true;
26 protected $diff = [];
27
37
43 {
44 $this->originalCollection = $originalCollection ?? new ExcludedDatesCollection([]);
45 $this->currentCollection = $currentCollection ?? new ExcludedDatesCollection([]);
46
47 $this->compare();
48 }
49
53 protected function compare(): void
54 {
55 $this->diff = array_udiff(
56 $this->currentCollection->getCollection(),
57 $this->originalCollection->getCollection(),
58 [$this, 'compareHandler']
59 );
60
61 if (
62 $this->diff
63 || $this->originalCollection->count() !== $this->currentCollection->count()
64 )
65 {
66 $this->isEqual = false;
67 }
68 }
69
74 {
75 return new ExcludedDatesCollection($this->diff);
76 }
77
81 public function isEqual(): bool
82 {
83 return $this->isEqual;
84 }
85
89 public function hasDiff(): bool
90 {
91 return (bool)$this->diff;
92 }
93
99 private function compareHandler(Date $current, Date $original): int
100 {
101 return $current->getTimestamp() <=> $original->getTimestamp();
102 }
103
107 public function getDiff(): array
108 {
109 return $this->diff;
110 }
111}
static createInstance(?ExcludedDatesCollection $originalCollection, ?ExcludedDatesCollection $currentCollection)
__construct(?ExcludedDatesCollection $originalCollection, ?ExcludedDatesCollection $currentCollection)