Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
excludeddatecomparemanager.php
1<?php
2
4
7
9{
21 protected $isEqual = true;
25 protected $diff = [];
26
36
42 {
43 $this->originalCollection = $originalCollection;
44 $this->currentCollection = $currentCollection;
45 }
46
51 {
52 $this->diff = array_udiff(
53 $this->currentCollection->getCollection(),
54 $this->originalCollection->getCollection(),
55 [$this, 'compareHandler']
56 );
57
58 if (
59 $this->diff
60 || $this->originalCollection->count() !== $this->currentCollection->count()
61 )
62 {
63 $this->isEqual = false;
64 }
65
66 return $this;
67 }
68
73 {
74 return new ExcludedDatesCollection($this->diff);
75 }
76
80 public function isEqual(): bool
81 {
82 return $this->isEqual;
83 }
84
88 public function hasDiff(): bool
89 {
90 return (bool)$this->diff;
91 }
92
98 private function compareHandler(Date $current, Date $original): int
99 {
100 return $current->getTimestamp() <=> $original->getTimestamp();
101 }
102}
static createInstance(?ExcludedDatesCollection $originalCollection, ?ExcludedDatesCollection $currentCollection)
__construct(?ExcludedDatesCollection $originalCollection, ?ExcludedDatesCollection $currentCollection)