aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/Component/VTodo.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/vobject/lib/Component/VTodo.php')
-rw-r--r--vendor/sabre/vobject/lib/Component/VTodo.php101
1 files changed, 55 insertions, 46 deletions
diff --git a/vendor/sabre/vobject/lib/Component/VTodo.php b/vendor/sabre/vobject/lib/Component/VTodo.php
index 9de77e841..144ced694 100644
--- a/vendor/sabre/vobject/lib/Component/VTodo.php
+++ b/vendor/sabre/vobject/lib/Component/VTodo.php
@@ -14,8 +14,8 @@ use Sabre\VObject;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class VTodo extends VObject\Component
-{
+class VTodo extends VObject\Component {
+
/**
* Returns true or false depending on if the event falls in the specified
* time-range. This is used for filtering purposes.
@@ -28,8 +28,8 @@ class VTodo extends VObject\Component
*
* @return bool
*/
- public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end)
- {
+ function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) {
+
$dtstart = isset($this->DTSTART) ? $this->DTSTART->getDateTime() : null;
$duration = isset($this->DURATION) ? VObject\DateTimeParser::parseDuration($this->DURATION) : null;
$due = isset($this->DUE) ? $this->DUE->getDateTime() : null;
@@ -39,7 +39,6 @@ class VTodo extends VObject\Component
if ($dtstart) {
if ($duration) {
$effectiveEnd = $dtstart->add($duration);
-
return $start <= $effectiveEnd && $end > $dtstart;
} elseif ($due) {
return
@@ -50,7 +49,7 @@ class VTodo extends VObject\Component
}
}
if ($due) {
- return $start < $due && $end >= $due;
+ return ($start < $due && $end >= $due);
}
if ($completed && $created) {
return
@@ -58,13 +57,13 @@ class VTodo extends VObject\Component
($end >= $created || $end >= $completed);
}
if ($completed) {
- return $start <= $completed && $end >= $completed;
+ return ($start <= $completed && $end >= $completed);
}
if ($created) {
- return $end > $created;
+ return ($end > $created);
}
-
return true;
+
}
/**
@@ -82,44 +81,45 @@ class VTodo extends VObject\Component
*
* @var array
*/
- public function getValidationRules()
- {
+ function getValidationRules() {
+
return [
- 'UID' => 1,
+ 'UID' => 1,
'DTSTAMP' => 1,
- 'CLASS' => '?',
- 'COMPLETED' => '?',
- 'CREATED' => '?',
- 'DESCRIPTION' => '?',
- 'DTSTART' => '?',
- 'GEO' => '?',
+ 'CLASS' => '?',
+ 'COMPLETED' => '?',
+ 'CREATED' => '?',
+ 'DESCRIPTION' => '?',
+ 'DTSTART' => '?',
+ 'GEO' => '?',
'LAST-MODIFIED' => '?',
- 'LOCATION' => '?',
- 'ORGANIZER' => '?',
- 'PERCENT' => '?',
- 'PRIORITY' => '?',
+ 'LOCATION' => '?',
+ 'ORGANIZER' => '?',
+ 'PERCENT' => '?',
+ 'PRIORITY' => '?',
'RECURRENCE-ID' => '?',
- 'SEQUENCE' => '?',
- 'STATUS' => '?',
- 'SUMMARY' => '?',
- 'URL' => '?',
+ 'SEQUENCE' => '?',
+ 'STATUS' => '?',
+ 'SUMMARY' => '?',
+ 'URL' => '?',
- 'RRULE' => '?',
- 'DUE' => '?',
+ 'RRULE' => '?',
+ 'DUE' => '?',
'DURATION' => '?',
- 'ATTACH' => '*',
- 'ATTENDEE' => '*',
- 'CATEGORIES' => '*',
- 'COMMENT' => '*',
- 'CONTACT' => '*',
- 'EXDATE' => '*',
+ 'ATTACH' => '*',
+ 'ATTENDEE' => '*',
+ 'CATEGORIES' => '*',
+ 'COMMENT' => '*',
+ 'CONTACT' => '*',
+ 'EXDATE' => '*',
'REQUEST-STATUS' => '*',
- 'RELATED-TO' => '*',
- 'RESOURCES' => '*',
- 'RDATE' => '*',
+ 'RELATED-TO' => '*',
+ 'RESOURCES' => '*',
+ 'RDATE' => '*',
];
+
}
/**
@@ -144,29 +144,36 @@ class VTodo extends VObject\Component
*
* @return array
*/
- public function validate($options = 0)
- {
+ function validate($options = 0) {
+
$result = parent::validate($options);
if (isset($this->DUE) && isset($this->DTSTART)) {
+
$due = $this->DUE;
$dtStart = $this->DTSTART;
if ($due->getValueType() !== $dtStart->getValueType()) {
+
$result[] = [
- 'level' => 3,
+ 'level' => 3,
'message' => 'The value type (DATE or DATE-TIME) must be identical for DUE and DTSTART',
- 'node' => $due,
+ 'node' => $due,
];
+
} elseif ($due->getDateTime() < $dtStart->getDateTime()) {
+
$result[] = [
- 'level' => 3,
+ 'level' => 3,
'message' => 'DUE must occur after DTSTART',
- 'node' => $due,
+ 'node' => $due,
];
+
}
+
}
return $result;
+
}
/**
@@ -174,11 +181,13 @@ class VTodo extends VObject\Component
*
* @return array
*/
- protected function getDefaults()
- {
+ protected function getDefaults() {
+
return [
- 'UID' => 'sabre-vobject-'.VObject\UUIDUtil::getUUID(),
+ 'UID' => 'sabre-vobject-' . VObject\UUIDUtil::getUUID(),
'DTSTAMP' => date('Ymd\\THis\\Z'),
];
+
}
+
}