aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/Property/ICalendar/Period.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/vobject/lib/Property/ICalendar/Period.php')
-rw-r--r--vendor/sabre/vobject/lib/Property/ICalendar/Period.php58
1 files changed, 38 insertions, 20 deletions
diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/Period.php b/vendor/sabre/vobject/lib/Property/ICalendar/Period.php
index 17bfa5c5c..d35b425aa 100644
--- a/vendor/sabre/vobject/lib/Property/ICalendar/Period.php
+++ b/vendor/sabre/vobject/lib/Property/ICalendar/Period.php
@@ -17,8 +17,8 @@ use Sabre\Xml;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Period extends Property
-{
+class Period extends Property {
+
/**
* In case this is a multi-value property. This string will be used as a
* delimiter.
@@ -34,10 +34,13 @@ class Period extends Property
* not yet done, but parameters are not included.
*
* @param string $val
+ *
+ * @return void
*/
- public function setRawMimeDirValue($val)
- {
+ function setRawMimeDirValue($val) {
+
$this->setValue(explode($this->delimiter, $val));
+
}
/**
@@ -45,9 +48,10 @@ class Period extends Property
*
* @return string
*/
- public function getRawMimeDirValue()
- {
+ function getRawMimeDirValue() {
+
return implode($this->delimiter, $this->getParts());
+
}
/**
@@ -58,9 +62,10 @@ class Period extends Property
*
* @return string
*/
- public function getValueType()
- {
+ function getValueType() {
+
return 'PERIOD';
+
}
/**
@@ -69,16 +74,21 @@ class Period extends Property
* The value must always be an array.
*
* @param array $value
+ *
+ * @return void
*/
- public function setJsonValue(array $value)
- {
+ function setJsonValue(array $value) {
+
$value = array_map(
- function ($item) {
+ function($item) {
+
return strtr(implode('/', $item), [':' => '', '-' => '']);
+
},
$value
);
parent::setJsonValue($value);
+
}
/**
@@ -88,19 +98,20 @@ class Period extends Property
*
* @return array
*/
- public function getJsonValue()
- {
+ function getJsonValue() {
+
$return = [];
foreach ($this->getParts() as $item) {
+
list($start, $end) = explode('/', $item, 2);
$start = DateTimeParser::parseDateTime($start);
// This is a duration value.
- if ('P' === $end[0]) {
+ if ($end[0] === 'P') {
$return[] = [
$start->format('Y-m-d\\TH:i:s'),
- $end,
+ $end
];
} else {
$end = DateTimeParser::parseDateTime($end);
@@ -109,29 +120,36 @@ class Period extends Property
$end->format('Y-m-d\\TH:i:s'),
];
}
+
}
return $return;
+
}
/**
* This method serializes only the value of a property. This is used to
* create xCard or xCal documents.
*
- * @param Xml\Writer $writer XML writer
+ * @param Xml\Writer $writer XML writer.
+ *
+ * @return void
*/
- protected function xmlSerializeValue(Xml\Writer $writer)
- {
+ protected function xmlSerializeValue(Xml\Writer $writer) {
+
$writer->startElement(strtolower($this->getValueType()));
$value = $this->getJsonValue();
$writer->writeElement('start', $value[0][0]);
- if ('P' === $value[0][1][0]) {
+ if ($value[0][1][0] === 'P') {
$writer->writeElement('duration', $value[0][1]);
- } else {
+ }
+ else {
$writer->writeElement('end', $value[0][1]);
}
$writer->endElement();
+
}
+
}