diff options
author | Mario Vavti <mario@mariovavti.com> | 2019-04-25 08:52:50 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2019-04-25 08:52:50 +0200 |
commit | e779335d060b3a51d6a144d23af4097ae6801473 (patch) | |
tree | 2427765313f715a0e5b48228abe5200cb82b787f /vendor/sabre/vobject/lib/Property/ICalendar | |
parent | e937e8fff96a935b14a479c062f6b0d00b90b99d (diff) | |
download | volse-hubzilla-e779335d060b3a51d6a144d23af4097ae6801473.tar.gz volse-hubzilla-e779335d060b3a51d6a144d23af4097ae6801473.tar.bz2 volse-hubzilla-e779335d060b3a51d6a144d23af4097ae6801473.zip |
update composer libs
Diffstat (limited to 'vendor/sabre/vobject/lib/Property/ICalendar')
6 files changed, 150 insertions, 233 deletions
diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/CalAddress.php b/vendor/sabre/vobject/lib/Property/ICalendar/CalAddress.php index a0c4a9b9a..e89bb31f9 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/CalAddress.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/CalAddress.php @@ -14,8 +14,8 @@ use * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class CalAddress extends Text { - +class CalAddress extends Text +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -32,10 +32,9 @@ class CalAddress extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'CAL-ADDRESS'; - } /** @@ -48,14 +47,14 @@ class CalAddress extends Text { * * @return string */ - function getNormalizedValue() { - + public function getNormalizedValue() + { $input = $this->getValue(); if (!strpos($input, ':')) { return $input; } list($schema, $everythingElse) = explode(':', $input, 2); - return strtolower($schema) . ':' . $everythingElse; + return strtolower($schema).':'.$everythingElse; } } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/Date.php b/vendor/sabre/vobject/lib/Property/ICalendar/Date.php index 378a0d60a..d8e86d13e 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/Date.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/Date.php @@ -13,6 +13,6 @@ namespace Sabre\VObject\Property\ICalendar; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Date extends DateTime { - +class Date extends DateTime +{ } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php b/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php index d580d4f68..7eb3e0bb7 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php @@ -24,8 +24,8 @@ use Sabre\VObject\TimeZoneUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class DateTime extends Property { - +class DateTime extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -40,17 +40,14 @@ class DateTime extends Property { * You may also specify DateTime objects here. * * @param array $parts - * - * @return void */ - function setParts(array $parts) { - + public function setParts(array $parts) + { if (isset($parts[0]) && $parts[0] instanceof DateTimeInterface) { $this->setDateTimes($parts); } else { parent::setParts($parts); } - } /** @@ -61,11 +58,9 @@ class DateTime extends Property { * Instead of strings, you may also use DateTime here. * * @param string|array|DateTimeInterface $value - * - * @return void */ - function setValue($value) { - + public function setValue($value) + { if (is_array($value) && isset($value[0]) && $value[0] instanceof DateTimeInterface) { $this->setDateTimes($value); } elseif ($value instanceof DateTimeInterface) { @@ -73,7 +68,6 @@ class DateTime extends Property { } else { parent::setValue($value); } - } /** @@ -83,13 +77,10 @@ class DateTime extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue(explode($this->delimiter, $val)); - } /** @@ -97,10 +88,9 @@ class DateTime extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return implode($this->delimiter, $this->getParts()); - } /** @@ -108,10 +98,9 @@ class DateTime extends Property { * * @return bool */ - function hasTime() { - - return strtoupper((string)$this['VALUE']) !== 'DATE'; - + public function hasTime() + { + return 'DATE' !== strtoupper((string) $this['VALUE']); } /** @@ -119,15 +108,14 @@ class DateTime extends Property { * * Note that DATE is always floating. */ - function isFloating() { - + public function isFloating() + { return !$this->hasTime() || ( !isset($this['TZID']) && - strpos($this->getValue(), 'Z') === false + false === strpos($this->getValue(), 'Z') ); - } /** @@ -143,15 +131,16 @@ class DateTime extends Property { * * @param DateTimeZone $timeZone * - * @return DateTimeImmutable + * @return \DateTimeImmutable */ - function getDateTime(DateTimeZone $timeZone = null) { - + public function getDateTime(DateTimeZone $timeZone = null) + { $dt = $this->getDateTimes($timeZone); - if (!$dt) return; + if (!$dt) { + return; + } return $dt[0]; - } /** @@ -163,38 +152,35 @@ class DateTime extends Property { * * @param DateTimeZone $timeZone * - * @return DateTimeImmutable[] + * @return \DateTimeImmutable[] * @return \DateTime[] */ - function getDateTimes(DateTimeZone $timeZone = null) { - + public function getDateTimes(DateTimeZone $timeZone = null) + { // Does the property have a TZID? $tzid = $this['TZID']; if ($tzid) { - $timeZone = TimeZoneUtil::getTimeZone((string)$tzid, $this->root); + $timeZone = TimeZoneUtil::getTimeZone((string) $tzid, $this->root); } $dts = []; foreach ($this->getParts() as $part) { $dts[] = DateTimeParser::parse($part, $timeZone); } - return $dts; + return $dts; } /** * Sets the property as a DateTime object. * * @param DateTimeInterface $dt - * @param bool isFloating If set to true, timezones will be ignored. - * - * @return void + * @param bool isFloating If set to true, timezones will be ignored */ - function setDateTime(DateTimeInterface $dt, $isFloating = false) { - + public function setDateTime(DateTimeInterface $dt, $isFloating = false) + { $this->setDateTimes([$dt], $isFloating); - } /** @@ -204,21 +190,17 @@ class DateTime extends Property { * the otehr values will be adjusted for that timezone * * @param DateTimeInterface[] $dt - * @param bool isFloating If set to true, timezones will be ignored. - * - * @return void + * @param bool isFloating If set to true, timezones will be ignored */ - function setDateTimes(array $dt, $isFloating = false) { - + public function setDateTimes(array $dt, $isFloating = false) + { $values = []; if ($this->hasTime()) { - $tz = null; $isUtc = false; foreach ($dt as $d) { - if ($isFloating) { $values[] = $d->format('Ymd\\THis'); continue; @@ -238,25 +220,18 @@ class DateTime extends Property { } else { $values[] = $d->format('Ymd\\THis'); } - } if ($isUtc || $isFloating) { $this->offsetUnset('TZID'); } - } else { - foreach ($dt as $d) { - $values[] = $d->format('Ymd'); - } $this->offsetUnset('TZID'); - } $this->value = $values; - } /** @@ -267,10 +242,9 @@ class DateTime extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return $this->hasTime() ? 'DATE-TIME' : 'DATE'; - } /** @@ -280,8 +254,8 @@ class DateTime extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $dts = $this->getDateTimes(); $hasTime = $this->hasTime(); $isFloating = $this->isFloating(); @@ -290,18 +264,15 @@ class DateTime extends Property { $isUtc = $isFloating ? false : in_array($tz->getName(), ['UTC', 'GMT', 'Z']); return array_map( - function(DateTimeInterface $dt) use ($hasTime, $isUtc) { - + function (DateTimeInterface $dt) use ($hasTime, $isUtc) { if ($hasTime) { - return $dt->format('Y-m-d\\TH:i:s') . ($isUtc ? 'Z' : ''); + return $dt->format('Y-m-d\\TH:i:s').($isUtc ? 'Z' : ''); } else { return $dt->format('Y-m-d'); } - }, $dts ); - } /** @@ -310,26 +281,21 @@ class DateTime extends Property { * The value must always be an array. * * @param array $value - * - * @return void */ - function setJsonValue(array $value) { - + public function setJsonValue(array $value) + { // dates and times in jCal have one difference to dates and times in // iCalendar. In jCal date-parts are separated by dashes, and // time-parts are separated by colons. It makes sense to just remove // those. $this->setValue( array_map( - function($item) { - + function ($item) { return strtr($item, [':' => '', '-' => '']); - }, $value ) ); - } /** @@ -337,20 +303,17 @@ class DateTime extends Property { * VALUE from DATE-TIME to DATE or vice-versa. * * @param string $name - * @param mixed $value - * - * @return void + * @param mixed $value */ - function offsetSet($name, $value) { - + public function offsetSet($name, $value) + { parent::offsetSet($name, $value); - if (strtoupper($name) !== 'VALUE') { + if ('VALUE' !== strtoupper($name)) { return; } // This will ensure that dates are correctly encoded. $this->setDateTimes($this->getDateTimes()); - } /** @@ -375,30 +338,30 @@ class DateTime extends Property { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $messages = parent::validate($options); $valueType = $this->getValueType(); $values = $this->getParts(); try { foreach ($values as $value) { switch ($valueType) { - case 'DATE' : + case 'DATE': DateTimeParser::parseDate($value); break; - case 'DATE-TIME' : + case 'DATE-TIME': DateTimeParser::parseDateTime($value); break; } } } catch (InvalidDataException $e) { $messages[] = [ - 'level' => 3, - 'message' => 'The supplied value (' . $value . ') is not a correct ' . $valueType, - 'node' => $this, + 'level' => 3, + 'message' => 'The supplied value ('.$value.') is not a correct '.$valueType, + 'node' => $this, ]; } - return $messages; + return $messages; } } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/Duration.php b/vendor/sabre/vobject/lib/Property/ICalendar/Duration.php index 7b7e1ce8e..87f008160 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/Duration.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/Duration.php @@ -16,8 +16,8 @@ use Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Duration extends Property { - +class Duration extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -33,13 +33,10 @@ class Duration extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue(explode($this->delimiter, $val)); - } /** @@ -47,10 +44,9 @@ class Duration extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return implode($this->delimiter, $this->getParts()); - } /** @@ -61,10 +57,9 @@ class Duration extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'DURATION'; - } /** @@ -74,12 +69,11 @@ class Duration extends Property { * * @return \DateInterval */ - function getDateInterval() { - + public function getDateInterval() + { $parts = $this->getParts(); $value = $parts[0]; - return DateTimeParser::parseDuration($value); + return DateTimeParser::parseDuration($value); } - } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/Period.php b/vendor/sabre/vobject/lib/Property/ICalendar/Period.php index d35b425aa..17bfa5c5c 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,13 +34,10 @@ class Period extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue(explode($this->delimiter, $val)); - } /** @@ -48,10 +45,9 @@ class Period extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return implode($this->delimiter, $this->getParts()); - } /** @@ -62,10 +58,9 @@ class Period extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'PERIOD'; - } /** @@ -74,21 +69,16 @@ class Period extends Property { * The value must always be an array. * * @param array $value - * - * @return void */ - function setJsonValue(array $value) { - + public function setJsonValue(array $value) + { $value = array_map( - function($item) { - + function ($item) { return strtr(implode('/', $item), [':' => '', '-' => '']); - }, $value ); parent::setJsonValue($value); - } /** @@ -98,20 +88,19 @@ class Period extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $return = []; foreach ($this->getParts() as $item) { - list($start, $end) = explode('/', $item, 2); $start = DateTimeParser::parseDateTime($start); // This is a duration value. - if ($end[0] === 'P') { + if ('P' === $end[0]) { $return[] = [ $start->format('Y-m-d\\TH:i:s'), - $end + $end, ]; } else { $end = DateTimeParser::parseDateTime($end); @@ -120,36 +109,29 @@ 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. - * - * @return void + * @param Xml\Writer $writer XML writer */ - 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 ($value[0][1][0] === 'P') { + if ('P' === $value[0][1][0]) { $writer->writeElement('duration', $value[0][1]); - } - else { + } else { $writer->writeElement('end', $value[0][1]); } $writer->endElement(); - } - } diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/Recur.php b/vendor/sabre/vobject/lib/Property/ICalendar/Recur.php index 434b77088..baeda781e 100644 --- a/vendor/sabre/vobject/lib/Property/ICalendar/Recur.php +++ b/vendor/sabre/vobject/lib/Property/ICalendar/Recur.php @@ -22,36 +22,33 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Recur extends Property { - +class Recur extends Property +{ /** * Updates the current value. * * This may be either a single, or multiple strings in an array. * * @param string|array $value - * - * @return void */ - function setValue($value) { - + public function setValue($value) + { // If we're getting the data from json, we'll be receiving an object if ($value instanceof \StdClass) { - $value = (array)$value; + $value = (array) $value; } if (is_array($value)) { $newVal = []; foreach ($value as $k => $v) { - if (is_string($v)) { $v = strtoupper($v); // The value had multiple sub-values - if (strpos($v, ',') !== false) { + if (false !== strpos($v, ',')) { $v = explode(',', $v); } - if (strcmp($k, 'until') === 0) { + if (0 === strcmp($k, 'until')) { $v = strtr($v, [':' => '', '-' => '']); } } elseif (is_array($v)) { @@ -66,7 +63,6 @@ class Recur extends Property { } else { throw new \InvalidArgumentException('You must either pass a string, or a key=>value array'); } - } /** @@ -80,26 +76,24 @@ class Recur extends Property { * * @return string */ - function getValue() { - + public function getValue() + { $out = []; foreach ($this->value as $key => $value) { - $out[] = $key . '=' . (is_array($value) ? implode(',', $value) : $value); + $out[] = $key.'='.(is_array($value) ? implode(',', $value) : $value); } - return strtoupper(implode(';', $out)); + return strtoupper(implode(';', $out)); } /** * Sets a multi-valued property. * * @param array $parts - * @return void */ - function setParts(array $parts) { - + public function setParts(array $parts) + { $this->setValue($parts); - } /** @@ -110,10 +104,9 @@ class Recur extends Property { * * @return array */ - function getParts() { - + public function getParts() + { return $this->value; - } /** @@ -123,13 +116,10 @@ class Recur extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue($val); - } /** @@ -137,10 +127,9 @@ class Recur extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return $this->getValue(); - } /** @@ -151,10 +140,9 @@ class Recur extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'RECUR'; - } /** @@ -164,39 +152,36 @@ class Recur extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $values = []; foreach ($this->getParts() as $k => $v) { - if (strcmp($k, 'UNTIL') === 0) { + if (0 === strcmp($k, 'UNTIL')) { $date = new DateTime($this->root, null, $v); $values[strtolower($k)] = $date->getJsonValue()[0]; - } elseif (strcmp($k, 'COUNT') === 0) { + } elseif (0 === strcmp($k, 'COUNT')) { $values[strtolower($k)] = intval($v); } else { $values[strtolower($k)] = $v; } } - return [$values]; + return [$values]; } /** * This method serializes only the value of a property. This is used to * create xCard or xCal documents. * - * @param Xml\Writer $writer XML writer. - * - * @return void + * @param Xml\Writer $writer XML writer */ - protected function xmlSerializeValue(Xml\Writer $writer) { - + protected function xmlSerializeValue(Xml\Writer $writer) + { $valueType = strtolower($this->getValueType()); foreach ($this->getJsonValue() as $value) { $writer->writeElement($valueType, $value); } - } /** @@ -206,12 +191,11 @@ class Recur extends Property { * * @return array */ - static function stringToArray($value) { - + public static function stringToArray($value) + { $value = strtoupper($value); $newValue = []; foreach (explode(';', $value) as $part) { - // Skipping empty parts. if (empty($part)) { continue; @@ -219,11 +203,10 @@ class Recur extends Property { list($partName, $partValue) = explode('=', $part); // The value itself had multiple values.. - if (strpos($partValue, ',') !== false) { + if (false !== strpos($partValue, ',')) { $partValue = explode(',', $partValue); } $newValue[$partName] = $partValue; - } return $newValue; @@ -251,32 +234,31 @@ class Recur extends Property { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $repair = ($options & self::REPAIR); $warnings = parent::validate($options); $values = $this->getParts(); foreach ($values as $key => $value) { - - if ($value === '') { + if ('' === $value) { $warnings[] = [ - 'level' => $repair ? 1 : 3, - 'message' => 'Invalid value for ' . $key . ' in ' . $this->name, - 'node' => $this + 'level' => $repair ? 1 : 3, + 'message' => 'Invalid value for '.$key.' in '.$this->name, + 'node' => $this, ]; if ($repair) { unset($values[$key]); } - } elseif ($key == 'BYMONTH') { - $byMonth = (array)$value; + } elseif ('BYMONTH' == $key) { + $byMonth = (array) $value; foreach ($byMonth as $i => $v) { - if (!is_numeric($v) || (int)$v < 1 || (int)$v > 12) { + if (!is_numeric($v) || (int) $v < 1 || (int) $v > 12) { $warnings[] = [ - 'level' => $repair ? 1 : 3, + 'level' => $repair ? 1 : 3, 'message' => 'BYMONTH in RRULE must have value(s) between 1 and 12!', - 'node' => $this + 'node' => $this, ]; if ($repair) { if (is_array($value)) { @@ -291,14 +273,14 @@ class Recur extends Property { if (is_array($value) && empty($values[$key])) { unset($values[$key]); } - } elseif ($key == 'BYWEEKNO') { - $byWeekNo = (array)$value; + } elseif ('BYWEEKNO' == $key) { + $byWeekNo = (array) $value; foreach ($byWeekNo as $i => $v) { - if (!is_numeric($v) || (int)$v < -53 || (int)$v == 0 || (int)$v > 53) { + if (!is_numeric($v) || (int) $v < -53 || 0 == (int) $v || (int) $v > 53) { $warnings[] = [ - 'level' => $repair ? 1 : 3, + 'level' => $repair ? 1 : 3, 'message' => 'BYWEEKNO in RRULE must have value(s) from -53 to -1, or 1 to 53!', - 'node' => $this + 'node' => $this, ]; if ($repair) { if (is_array($value)) { @@ -313,14 +295,14 @@ class Recur extends Property { if (is_array($value) && empty($values[$key])) { unset($values[$key]); } - } elseif ($key == 'BYYEARDAY') { - $byYearDay = (array)$value; + } elseif ('BYYEARDAY' == $key) { + $byYearDay = (array) $value; foreach ($byYearDay as $i => $v) { - if (!is_numeric($v) || (int)$v < -366 || (int)$v == 0 || (int)$v > 366) { + if (!is_numeric($v) || (int) $v < -366 || 0 == (int) $v || (int) $v > 366) { $warnings[] = [ - 'level' => $repair ? 1 : 3, + 'level' => $repair ? 1 : 3, 'message' => 'BYYEARDAY in RRULE must have value(s) from -366 to -1, or 1 to 366!', - 'node' => $this + 'node' => $this, ]; if ($repair) { if (is_array($value)) { @@ -336,13 +318,12 @@ class Recur extends Property { unset($values[$key]); } } - } if (!isset($values['FREQ'])) { $warnings[] = [ - 'level' => $repair ? 1 : 3, - 'message' => 'FREQ is required in ' . $this->name, - 'node' => $this + 'level' => $repair ? 1 : 3, + 'message' => 'FREQ is required in '.$this->name, + 'node' => $this, ]; if ($repair) { $this->parent->remove($this); @@ -353,7 +334,5 @@ class Recur extends Property { } return $warnings; - } - } |