aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/FreeBusyData.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-04-25 11:47:18 +0200
committerMario Vavti <mario@mariovavti.com>2019-04-25 11:47:18 +0200
commita60c2f38c689f254bd8bb8e7ea9af78bf21c1f84 (patch)
tree65d1d73918ccb1d4ccc36184d70af2e8dd91f28e /vendor/sabre/vobject/lib/FreeBusyData.php
parentf1c07977809ce3221286d53e99f0d91145b1166f (diff)
downloadvolse-hubzilla-a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84.tar.gz
volse-hubzilla-a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84.tar.bz2
volse-hubzilla-a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84.zip
update sabre/vobject
Diffstat (limited to 'vendor/sabre/vobject/lib/FreeBusyData.php')
-rw-r--r--vendor/sabre/vobject/lib/FreeBusyData.php68
1 files changed, 30 insertions, 38 deletions
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;
-
}
-
}