59 if (
$start > $this->end || $end < $this->start) {
66 if ($start < $this->start) {
70 if (
$end > $this->end) {
77 while (
$start > $this->
data[$currentIndex][
'end']) {
83 $insertStartIndex = $currentIndex + 1;
91 $preceedingItem = $this->
data[$insertStartIndex - 1];
92 if ($this->
data[$insertStartIndex - 1][
'start'] ===
$start) {
101 if ($insertStartIndex > 0) {
102 $currentIndex = $insertStartIndex - 1;
107 while (
$end > $this->
data[$currentIndex][
'end']) {
120 $itemsToDelete = $currentIndex - $insertStartIndex;
121 if ($this->
data[$currentIndex][
'end'] <=
$end) $itemsToDelete++;
127 if ($itemsToDelete === -1) {
129 if ($newItem[
'end'] < $preceedingItem[
'end']) {
131 'start' => $newItem[
'end'] + 1,
132 'end' => $preceedingItem[
'end'],
133 'type' => $preceedingItem[
'type']
146 $mergeOffset = $insertStartIndex;
147 $mergeItem = $newItem;
150 if (isset($this->
data[$insertStartIndex - 1])) {
152 $this->
data[$insertStartIndex - 1][
'end'] =
$start;
156 if ($this->
data[$insertStartIndex - 1][
'type'] === $this->
data[$insertStartIndex][
'type']) {
160 $mergeItem[
'start'] = $this->
data[$insertStartIndex - 1][
'start'];
163 if (isset($this->
data[$insertStartIndex + 1])) {
165 $this->
data[$insertStartIndex + 1][
'start'] =
$end;
169 if ($this->
data[$insertStartIndex + 1][
'type'] === $this->
data[$insertStartIndex][
'type']) {
172 $mergeItem[
'end'] = $this->
data[$insertStartIndex + 1][
'end'];
FreeBusyData is a helper class that manages freebusy information.
add($start, $end, $type)
Adds free or busytime to the data.
__construct($start, $end)