From a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 25 Apr 2019 11:47:18 +0200 Subject: update sabre/vobject --- vendor/sabre/vobject/lib/FreeBusyData.php | 68 ++++++++++++++----------------- 1 file changed, 30 insertions(+), 38 deletions(-) (limited to 'vendor/sabre/vobject/lib/FreeBusyData.php') diff --git a/vendor/sabre/vobject/lib/FreeBusyData.php b/vendor/sabre/vobject/lib/FreeBusyData.php index 0a6c72bb2..d05dfc799 100644 --- a/vendor/sabre/vobject/lib/FreeBusyData.php +++ b/vendor/sabre/vobject/lib/FreeBusyData.php @@ -9,17 +9,17 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class FreeBusyData { - +class FreeBusyData +{ /** - * Start timestamp + * Start timestamp. * * @var int */ protected $start; /** - * End timestamp + * End timestamp. * * @var int */ @@ -32,35 +32,31 @@ class FreeBusyData { */ protected $data; - function __construct($start, $end) { - + public function __construct($start, $end) + { $this->start = $start; $this->end = $end; $this->data = []; $this->data[] = [ 'start' => $this->start, - 'end' => $this->end, - 'type' => 'FREE', + 'end' => $this->end, + 'type' => 'FREE', ]; - } /** * Adds free or busytime to the data. * - * @param int $start - * @param int $end - * @param string $type FREE, BUSY, BUSY-UNAVAILABLE or BUSY-TENTATIVE - * @return void + * @param int $start + * @param int $end + * @param string $type FREE, BUSY, BUSY-UNAVAILABLE or BUSY-TENTATIVE */ - function add($start, $end, $type) { - + public function add($start, $end, $type) + { if ($start > $this->end || $end < $this->start) { - // This new data is outside our timerange. return; - } if ($start < $this->start) { @@ -75,7 +71,7 @@ class FreeBusyData { // Finding out where we need to insert the new item. $currentIndex = 0; while ($start > $this->data[$currentIndex]['end']) { - $currentIndex++; + ++$currentIndex; } // The standard insertion point will be one _after_ the first @@ -84,14 +80,14 @@ class FreeBusyData { $newItem = [ 'start' => $start, - 'end' => $end, - 'type' => $type, + 'end' => $end, + 'type' => $type, ]; $preceedingItem = $this->data[$insertStartIndex - 1]; if ($this->data[$insertStartIndex - 1]['start'] === $start) { // The old item starts at the exact same point as the new item. - $insertStartIndex--; + --$insertStartIndex; } // Now we know where to insert the item, we need to know where it @@ -105,32 +101,32 @@ class FreeBusyData { } while ($end > $this->data[$currentIndex]['end']) { - - $currentIndex++; - + ++$currentIndex; } // What we are about to insert into the array $newItems = [ - $newItem + $newItem, ]; // This is the amount of items that are completely overwritten by the // new item. $itemsToDelete = $currentIndex - $insertStartIndex; - if ($this->data[$currentIndex]['end'] <= $end) $itemsToDelete++; + if ($this->data[$currentIndex]['end'] <= $end) { + ++$itemsToDelete; + } // If itemsToDelete was -1, it means that the newly inserted item is // actually sitting inside an existing one. This means we need to split // the item at the current position in two and insert the new item in // between. - if ($itemsToDelete === -1) { + if (-1 === $itemsToDelete) { $itemsToDelete = 0; if ($newItem['end'] < $preceedingItem['end']) { $newItems[] = [ 'start' => $newItem['end'] + 1, - 'end' => $preceedingItem['end'], - 'type' => $preceedingItem['type'] + 'end' => $preceedingItem['end'], + 'type' => $preceedingItem['type'], ]; } } @@ -155,8 +151,8 @@ class FreeBusyData { // merge them into one item. if ($this->data[$insertStartIndex - 1]['type'] === $this->data[$insertStartIndex]['type']) { $doMerge = true; - $mergeOffset--; - $mergeDelete++; + --$mergeOffset; + ++$mergeDelete; $mergeItem['start'] = $this->data[$insertStartIndex - 1]['start']; } } @@ -168,10 +164,9 @@ class FreeBusyData { // merge them into one item. if ($this->data[$insertStartIndex + 1]['type'] === $this->data[$insertStartIndex]['type']) { $doMerge = true; - $mergeDelete++; + ++$mergeDelete; $mergeItem['end'] = $this->data[$insertStartIndex + 1]['end']; } - } if ($doMerge) { array_splice( @@ -181,13 +176,10 @@ class FreeBusyData { [$mergeItem] ); } - } - function getData() { - + public function getData() + { return $this->data; - } - } -- cgit v1.2.3