diff options
author | Mario Vavti <mario@mariovavti.com> | 2019-04-25 11:47:18 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2019-04-25 11:47:18 +0200 |
commit | a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84 (patch) | |
tree | 65d1d73918ccb1d4ccc36184d70af2e8dd91f28e /vendor/sabre/vobject/lib/Property | |
parent | f1c07977809ce3221286d53e99f0d91145b1166f (diff) | |
download | volse-hubzilla-a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84.tar.gz volse-hubzilla-a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84.tar.bz2 volse-hubzilla-a60c2f38c689f254bd8bb8e7ea9af78bf21c1f84.zip |
update sabre/vobject
Diffstat (limited to 'vendor/sabre/vobject/lib/Property')
21 files changed, 388 insertions, 624 deletions
diff --git a/vendor/sabre/vobject/lib/Property/Binary.php b/vendor/sabre/vobject/lib/Property/Binary.php index d54cae25d..830dd9028 100644 --- a/vendor/sabre/vobject/lib/Property/Binary.php +++ b/vendor/sabre/vobject/lib/Property/Binary.php @@ -18,8 +18,8 @@ use Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Binary extends Property { - +class Binary extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -34,25 +34,18 @@ class Binary extends Property { * 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 (is_array($value)) { - - if (count($value) === 1) { + if (1 === count($value)) { $this->value = $value[0]; } else { throw new \InvalidArgumentException('The argument must either be a string or an array with only one child'); } - } else { - $this->value = $value; - } - } /** @@ -62,13 +55,10 @@ class Binary extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->value = base64_decode($val); - } /** @@ -76,10 +66,9 @@ class Binary extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return base64_encode($this->value); - } /** @@ -90,10 +79,9 @@ class Binary extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'BINARY'; - } /** @@ -103,10 +91,9 @@ class Binary extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { return [base64_encode($this->getValue())]; - } /** @@ -115,14 +102,10 @@ class Binary 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('base64_decode', $value); parent::setJsonValue($value); - } - } diff --git a/vendor/sabre/vobject/lib/Property/Boolean.php b/vendor/sabre/vobject/lib/Property/Boolean.php index 6f5887e25..1b219bb8c 100644 --- a/vendor/sabre/vobject/lib/Property/Boolean.php +++ b/vendor/sabre/vobject/lib/Property/Boolean.php @@ -17,8 +17,8 @@ use * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Boolean extends Property { - +class Boolean extends Property +{ /** * Sets a raw value coming from a mimedir (iCalendar/vCard) file. * @@ -26,14 +26,11 @@ class Boolean extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - - $val = strtoupper($val) === 'TRUE' ? true : false; + public function setRawMimeDirValue($val) + { + $val = 'TRUE' === strtoupper($val) ? true : false; $this->setValue($val); - } /** @@ -41,10 +38,9 @@ class Boolean extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return $this->value ? 'TRUE' : 'FALSE'; - } /** @@ -55,10 +51,9 @@ class Boolean extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'BOOLEAN'; - } /** @@ -66,19 +61,15 @@ class Boolean extends Property { * object. * * @param array $value - * - * @return void */ - function setXmlValue(array $value) { - + public function setXmlValue(array $value) + { $value = array_map( - function($value) { + function ($value) { return 'true' === $value; }, $value ); parent::setXmlValue($value); - } - } diff --git a/vendor/sabre/vobject/lib/Property/FlatText.php b/vendor/sabre/vobject/lib/Property/FlatText.php index 2c7b43c29..d15cfe051 100644 --- a/vendor/sabre/vobject/lib/Property/FlatText.php +++ b/vendor/sabre/vobject/lib/Property/FlatText.php @@ -22,8 +22,8 @@ namespace Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class FlatText extends Text { - +class FlatText extends Text +{ /** * Field separator. * @@ -37,14 +37,10 @@ class FlatText extends Text { * Overriding this so we're not splitting on a ; delimiter. * * @param string $val - * - * @return void */ - function setQuotedPrintableValue($val) { - + public function setQuotedPrintableValue($val) + { $val = quoted_printable_decode($val); $this->setValue($val); - } - } diff --git a/vendor/sabre/vobject/lib/Property/FloatValue.php b/vendor/sabre/vobject/lib/Property/FloatValue.php index 15b119549..208d74516 100644 --- a/vendor/sabre/vobject/lib/Property/FloatValue.php +++ b/vendor/sabre/vobject/lib/Property/FloatValue.php @@ -15,8 +15,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class FloatValue extends Property { - +class FloatValue extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -32,17 +32,14 @@ class FloatValue extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $val = explode($this->delimiter, $val); foreach ($val as &$item) { - $item = (float)$item; + $item = (float) $item; } $this->setParts($val); - } /** @@ -50,13 +47,12 @@ class FloatValue extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return implode( $this->delimiter, $this->getParts() ); - } /** @@ -67,10 +63,9 @@ class FloatValue extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'FLOAT'; - } /** @@ -80,20 +75,19 @@ class FloatValue extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $val = array_map('floatval', $this->getParts()); // Special-casing the GEO property. // // See: // http://tools.ietf.org/html/draft-ietf-jcardcal-jcal-04#section-3.4.1.2 - if ($this->name === 'GEO') { + if ('GEO' === $this->name) { return [$val]; } return $val; - } /** @@ -101,42 +95,32 @@ class FloatValue extends Property { * object. * * @param array $value - * - * @return void */ - function setXmlValue(array $value) { - + public function setXmlValue(array $value) + { $value = array_map('floatval', $value); parent::setXmlValue($value); - } /** * 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) + { // Special-casing the GEO property. // // See: // http://tools.ietf.org/html/rfc6321#section-3.4.1.2 - if ($this->name === 'GEO') { - + if ('GEO' === $this->name) { $value = array_map('floatval', $this->getParts()); $writer->writeElement('latitude', $value[0]); $writer->writeElement('longitude', $value[1]); - - } - else { + } else { parent::xmlSerializeValue($writer); } - } - } 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; - } - } diff --git a/vendor/sabre/vobject/lib/Property/IntegerValue.php b/vendor/sabre/vobject/lib/Property/IntegerValue.php index 5bd1887fa..ddd71d731 100644 --- a/vendor/sabre/vobject/lib/Property/IntegerValue.php +++ b/vendor/sabre/vobject/lib/Property/IntegerValue.php @@ -15,8 +15,8 @@ use * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class IntegerValue extends Property { - +class IntegerValue extends Property +{ /** * Sets a raw value coming from a mimedir (iCalendar/vCard) file. * @@ -24,13 +24,10 @@ class IntegerValue extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - - $this->setValue((int)$val); - + public function setRawMimeDirValue($val) + { + $this->setValue((int) $val); } /** @@ -38,10 +35,9 @@ class IntegerValue extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return $this->value; - } /** @@ -52,10 +48,9 @@ class IntegerValue extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'INTEGER'; - } /** @@ -65,10 +60,9 @@ class IntegerValue extends Property { * * @return array */ - function getJsonValue() { - - return [(int)$this->getValue()]; - + public function getJsonValue() + { + return [(int) $this->getValue()]; } /** @@ -76,13 +70,10 @@ class IntegerValue extends Property { * object. * * @param array $value - * - * @return void */ - function setXmlValue(array $value) { - + public function setXmlValue(array $value) + { $value = array_map('intval', $value); parent::setXmlValue($value); - } } diff --git a/vendor/sabre/vobject/lib/Property/Text.php b/vendor/sabre/vobject/lib/Property/Text.php index 47a86ccc9..23c945551 100644 --- a/vendor/sabre/vobject/lib/Property/Text.php +++ b/vendor/sabre/vobject/lib/Property/Text.php @@ -17,8 +17,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Text extends Property { - +class Text extends Property +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -53,7 +53,7 @@ class Text extends Property { * @var array */ protected $minimumPropertyValues = [ - 'N' => 5, + 'N' => 5, 'ADR' => 7, ]; @@ -64,16 +64,14 @@ class Text extends Property { * parameters will automatically be created, or you can just pass a list of * Parameter objects. * - * @param Component $root The root document - * @param string $name + * @param Component $root The root document + * @param string $name * @param string|array|null $value - * @param array $parameters List of parameters - * @param string $group The vcard property group - * - * @return void + * @param array $parameters List of parameters + * @param string $group The vcard property group */ - function __construct(Component $root, $name, $value = null, array $parameters = [], $group = null) { - + public function __construct(Component $root, $name, $value = null, array $parameters = [], $group = null) + { // There's two types of multi-valued text properties: // 1. multivalue properties. // 2. structured value properties @@ -84,7 +82,6 @@ class Text extends Property { } parent::__construct($root, $name, $value, $parameters, $group); - } /** @@ -94,24 +91,19 @@ class Text extends Property { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { $this->setValue(MimeDir::unescapeValue($val, $this->delimiter)); - } /** * Sets the value as a quoted-printable encoded string. * * @param string $val - * - * @return void */ - function setQuotedPrintableValue($val) { - + public function setQuotedPrintableValue($val) + { $val = quoted_printable_decode($val); // Quoted printable only appears in vCard 2.1, and the only character @@ -123,7 +115,6 @@ class Text extends Property { $regex = '# (?<!\\\\) ; #x'; $matches = preg_split($regex, $val); $this->setValue($matches); - } /** @@ -131,8 +122,8 @@ class Text extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { $val = $this->getParts(); if (isset($this->minimumPropertyValues[$this->name])) { @@ -140,7 +131,6 @@ class Text extends Property { } foreach ($val as &$item) { - if (!is_array($item)) { $item = [$item]; } @@ -150,19 +140,17 @@ class Text extends Property { $subItem, [ '\\' => '\\\\', - ';' => '\;', - ',' => '\,', + ';' => '\;', + ',' => '\,', "\n" => '\n', - "\r" => "", + "\r" => '', ] ); } $item = implode(',', $item); - } return implode($this->delimiter, $val); - } /** @@ -172,16 +160,16 @@ class Text extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { // Structured text values should always be returned as a single // array-item. Multi-value text should be returned as multiple items in // the top-array. if (in_array($this->name, $this->structuredValues)) { return [$this->getParts()]; } - return $this->getParts(); + return $this->getParts(); } /** @@ -192,10 +180,9 @@ class Text extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'TEXT'; - } /** @@ -203,10 +190,10 @@ class Text extends Property { * * @return string */ - function serialize() { - + public function serialize() + { // We need to kick in a special type of encoding, if it's a 2.1 vcard. - if ($this->root->getDocumentType() !== Document::VCARD21) { + if (Document::VCARD21 !== $this->root->getDocumentType()) { return parent::serialize(); } @@ -228,22 +215,19 @@ class Text extends Property { } $str = $this->name; - if ($this->group) $str = $this->group . '.' . $this->name; + if ($this->group) { + $str = $this->group.'.'.$this->name; + } foreach ($this->parameters as $param) { - - if ($param->getValue() === 'QUOTED-PRINTABLE') { + if ('QUOTED-PRINTABLE' === $param->getValue()) { continue; } - $str .= ';' . $param->serialize(); - + $str .= ';'.$param->serialize(); } - - // If the resulting value contains a \n, we must encode it as // quoted-printable. - if (\strpos($val, "\n") !== false) { - + if (false !== \strpos($val, "\n")) { $str .= ';ENCODING=QUOTED-PRINTABLE:'; $lastLine = $str; $out = null; @@ -252,26 +236,27 @@ class Text extends Property { // encode newlines for us. Specifically, the \r\n sequence must in // vcards be encoded as =0D=OA and we must insert soft-newlines // every 75 bytes. - for ($ii = 0;$ii < \strlen($val);$ii++) { + for ($ii = 0; $ii < \strlen($val); ++$ii) { $ord = \ord($val[$ii]); // These characters are encoded as themselves. if ($ord >= 32 && $ord <= 126) { $lastLine .= $val[$ii]; } else { - $lastLine .= '=' . \strtoupper(\bin2hex($val[$ii])); + $lastLine .= '='.\strtoupper(\bin2hex($val[$ii])); } if (\strlen($lastLine) >= 75) { // Soft line break - $out .= $lastLine . "=\r\n "; + $out .= $lastLine."=\r\n "; $lastLine = null; } - } - if (!\is_null($lastLine)) $out .= $lastLine . "\r\n"; - return $out; + if (!\is_null($lastLine)) { + $out .= $lastLine."\r\n"; + } + return $out; } else { - $str .= ':' . $val; + $str .= ':'.$val; $str = \preg_replace( '/( @@ -285,24 +270,20 @@ class Text extends Property { // remove single space after last CRLF return \substr($str, 0, -1); - } - } /** * 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) + { $values = $this->getParts(); - $map = function($items) use ($values, $writer) { + $map = function ($items) use ($values, $writer) { foreach ($items as $i => $item) { $writer->writeElement( $item, @@ -312,7 +293,6 @@ class Text extends Property { }; switch ($this->name) { - // Special-casing the REQUEST-STATUS property. // // See: @@ -332,14 +312,14 @@ class Text extends Property { 'given', 'additional', 'prefix', - 'suffix' + 'suffix', ]); break; case 'GENDER': $map([ 'sex', - 'text' + 'text', ]); break; @@ -351,21 +331,20 @@ class Text extends Property { 'locality', 'region', 'code', - 'country' + 'country', ]); break; case 'CLIENTPIDMAP': $map([ 'sourceid', - 'uri' + 'uri', ]); break; default: parent::xmlSerializeValue($writer); } - } /** @@ -386,28 +365,26 @@ class Text extends Property { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $warnings = parent::validate($options); if (isset($this->minimumPropertyValues[$this->name])) { - $minimum = $this->minimumPropertyValues[$this->name]; $parts = $this->getParts(); if (count($parts) < $minimum) { $warnings[] = [ - 'level' => $options & self::REPAIR ? 1 : 3, - 'message' => 'The ' . $this->name . ' property must have at least ' . $minimum . ' values. It only has ' . count($parts), - 'node' => $this, + 'level' => $options & self::REPAIR ? 1 : 3, + 'message' => 'The '.$this->name.' property must have at least '.$minimum.' values. It only has '.count($parts), + 'node' => $this, ]; if ($options & self::REPAIR) { $parts = array_pad($parts, $minimum, ''); $this->setParts($parts); } } - } - return $warnings; + return $warnings; } } diff --git a/vendor/sabre/vobject/lib/Property/Time.php b/vendor/sabre/vobject/lib/Property/Time.php index dbafc3b85..7aeafc8d0 100644 --- a/vendor/sabre/vobject/lib/Property/Time.php +++ b/vendor/sabre/vobject/lib/Property/Time.php @@ -13,8 +13,8 @@ use Sabre\VObject\DateTimeParser; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Time extends Text { - +class Time extends Text +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -31,10 +31,9 @@ class Time extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'TIME'; - } /** @@ -43,11 +42,9 @@ class Time extends Text { * The value must always be an array. * * @param array $value - * - * @return void */ - function setJsonValue(array $value) { - + public function setJsonValue(array $value) + { // Removing colons from value. $value = str_replace( ':', @@ -55,12 +52,11 @@ class Time extends Text { $value ); - if (count($value) === 1) { + if (1 === count($value)) { $this->setValue(reset($value)); } else { $this->setValue($value); } - } /** @@ -70,8 +66,8 @@ class Time extends Text { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $parts = DateTimeParser::parseVCardTime($this->getValue()); $timeStr = ''; @@ -109,7 +105,7 @@ class Time extends Text { // Timezone if (!is_null($parts['timezone'])) { - if ($parts['timezone'] === 'Z') { + if ('Z' === $parts['timezone']) { $timeStr .= 'Z'; } else { $timeStr .= @@ -118,7 +114,6 @@ class Time extends Text { } return [$timeStr]; - } /** @@ -126,19 +121,15 @@ class Time extends Text { * object. * * @param array $value - * - * @return void */ - function setXmlValue(array $value) { - + public function setXmlValue(array $value) + { $value = array_map( - function($value) { + function ($value) { return str_replace(':', '', $value); }, $value ); parent::setXmlValue($value); - } - } diff --git a/vendor/sabre/vobject/lib/Property/Unknown.php b/vendor/sabre/vobject/lib/Property/Unknown.php index 7a3373868..6f404c286 100644 --- a/vendor/sabre/vobject/lib/Property/Unknown.php +++ b/vendor/sabre/vobject/lib/Property/Unknown.php @@ -12,8 +12,8 @@ namespace Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Unknown extends Text { - +class Unknown extends Text +{ /** * Returns the value, in the format it should be encoded for json. * @@ -21,10 +21,9 @@ class Unknown extends Text { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { return [$this->getRawMimeDirValue()]; - } /** @@ -35,10 +34,8 @@ class Unknown extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'UNKNOWN'; - } - } diff --git a/vendor/sabre/vobject/lib/Property/Uri.php b/vendor/sabre/vobject/lib/Property/Uri.php index 88fcfaab8..3449ba1f2 100644 --- a/vendor/sabre/vobject/lib/Property/Uri.php +++ b/vendor/sabre/vobject/lib/Property/Uri.php @@ -14,8 +14,8 @@ use Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Uri extends Text { - +class Uri extends Text +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -32,10 +32,9 @@ class Uri extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'URI'; - } /** @@ -43,8 +42,8 @@ class Uri extends Text { * * @return array */ - function parameters() { - + public function parameters() + { $parameters = parent::parameters(); if (!isset($parameters['VALUE']) && in_array($this->name, ['URL', 'PHOTO'])) { // If we are encoding a URI value, and this URI value has no @@ -57,8 +56,8 @@ class Uri extends Text { // See Issue #227 and #235 $parameters['VALUE'] = new Parameter($this->root, 'VALUE', 'URI'); } - return $parameters; + return $parameters; } /** @@ -68,11 +67,9 @@ class Uri extends Text { * not yet done, but parameters are not included. * * @param string $val - * - * @return void */ - function setRawMimeDirValue($val) { - + public function setRawMimeDirValue($val) + { // Normally we don't need to do any type of unescaping for these // properties, however.. we've noticed that Google Contacts // specifically escapes the colon (:) with a blackslash. While I have @@ -81,16 +78,16 @@ class Uri extends Text { // // Good thing backslashes are not allowed in urls. Makes it easy to // assume that a backslash is always intended as an escape character. - if ($this->name === 'URL') { + if ('URL' === $this->name) { $regex = '# (?: (\\\\ (?: \\\\ | : ) ) ) #x'; $matches = preg_split($regex, $val, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $newVal = ''; foreach ($matches as $match) { switch ($match) { - case '\:' : + case '\:': $newVal .= ':'; break; - default : + default: $newVal .= $match; break; } @@ -99,7 +96,6 @@ class Uri extends Text { } else { $this->value = strtr($val, ['\,' => ',']); } - } /** @@ -107,8 +103,8 @@ class Uri extends Text { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { if (is_array($this->value)) { $value = $this->value[0]; } else { @@ -116,7 +112,5 @@ class Uri extends Text { } return strtr($value, [',' => '\,']); - } - } diff --git a/vendor/sabre/vobject/lib/Property/UtcOffset.php b/vendor/sabre/vobject/lib/Property/UtcOffset.php index 61895c48e..732239e23 100644 --- a/vendor/sabre/vobject/lib/Property/UtcOffset.php +++ b/vendor/sabre/vobject/lib/Property/UtcOffset.php @@ -11,8 +11,8 @@ namespace Sabre\VObject\Property; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class UtcOffset extends Text { - +class UtcOffset extends Text +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -29,10 +29,9 @@ class UtcOffset extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'UTC-OFFSET'; - } /** @@ -41,19 +40,16 @@ class UtcOffset extends Text { * 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($value) { + function ($value) { return str_replace(':', '', $value); }, $value ); parent::setJsonValue($value); - } /** @@ -63,15 +59,14 @@ class UtcOffset extends Text { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { return array_map( - function($value) { - return substr($value, 0, -2) . ':' . + function ($value) { + return substr($value, 0, -2).':'. substr($value, -2); }, parent::getJsonValue() ); - } } diff --git a/vendor/sabre/vobject/lib/Property/VCard/Date.php b/vendor/sabre/vobject/lib/Property/VCard/Date.php index 1ef6dff34..a018ccbb8 100644 --- a/vendor/sabre/vobject/lib/Property/VCard/Date.php +++ b/vendor/sabre/vobject/lib/Property/VCard/Date.php @@ -11,8 +11,8 @@ namespace Sabre\VObject\Property\VCard; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Date extends DateAndOrTime { - +class Date extends DateAndOrTime +{ /** * Returns the type of value. * @@ -21,23 +21,18 @@ class Date extends DateAndOrTime { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'DATE'; - } /** * Sets the property as a DateTime object. * * @param \DateTimeInterface $dt - * - * @return void */ - function setDateTime(\DateTimeInterface $dt) { - + public function setDateTime(\DateTimeInterface $dt) + { $this->value = $dt->format('Ymd'); - } - } diff --git a/vendor/sabre/vobject/lib/Property/VCard/DateAndOrTime.php b/vendor/sabre/vobject/lib/Property/VCard/DateAndOrTime.php index 3b4ae3bb5..b7e17492a 100644 --- a/vendor/sabre/vobject/lib/Property/VCard/DateAndOrTime.php +++ b/vendor/sabre/vobject/lib/Property/VCard/DateAndOrTime.php @@ -19,12 +19,12 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class DateAndOrTime extends Property { - +class DateAndOrTime extends Property +{ /** * Field separator. * - * @var null|string + * @var string|null */ public $delimiter = null; @@ -36,10 +36,9 @@ class DateAndOrTime extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'DATE-AND-OR-TIME'; - } /** @@ -48,11 +47,9 @@ class DateAndOrTime extends Property { * You may also specify DateTimeInterface objects here. * * @param array $parts - * - * @return void */ - function setParts(array $parts) { - + public function setParts(array $parts) + { if (count($parts) > 1) { throw new \InvalidArgumentException('Only one value allowed'); } @@ -61,7 +58,6 @@ class DateAndOrTime extends Property { } else { parent::setParts($parts); } - } /** @@ -72,28 +68,23 @@ class DateAndOrTime extends Property { * Instead of strings, you may also use DateTimeInterface here. * * @param string|array|DateTimeInterface $value - * - * @return void */ - function setValue($value) { - + public function setValue($value) + { if ($value instanceof DateTimeInterface) { $this->setDateTime($value); } else { parent::setValue($value); } - } /** * Sets the property as a DateTime object. * * @param DateTimeInterface $dt - * - * @return void */ - function setDateTime(DateTimeInterface $dt) { - + public function setDateTime(DateTimeInterface $dt) + { $tz = $dt->getTimeZone(); $isUtc = in_array($tz->getName(), ['UTC', 'GMT', 'Z']); @@ -105,7 +96,6 @@ class DateAndOrTime extends Property { } $this->value = $value; - } /** @@ -124,12 +114,12 @@ class DateAndOrTime extends Property { * * @return DateTimeImmutable */ - function getDateTime() { - + public function getDateTime() + { $now = new DateTime(); - $tzFormat = $now->getTimezone()->getOffset($now) === 0 ? '\\Z' : 'O'; - $nowParts = DateTimeParser::parseVCardDateTime($now->format('Ymd\\This' . $tzFormat)); + $tzFormat = 0 === $now->getTimezone()->getOffset($now) ? '\\Z' : 'O'; + $nowParts = DateTimeParser::parseVCardDateTime($now->format('Ymd\\This'.$tzFormat)); $dateParts = DateTimeParser::parseVCardDateTime($this->getValue()); @@ -141,8 +131,8 @@ class DateAndOrTime extends Property { $dateParts[$k] = $nowParts[$k]; } } - return new DateTimeImmutable("$dateParts[year]-$dateParts[month]-$dateParts[date] $dateParts[hour]:$dateParts[minute]:$dateParts[second] $dateParts[timezone]"); + return new DateTimeImmutable("$dateParts[year]-$dateParts[month]-$dateParts[date] $dateParts[hour]:$dateParts[minute]:$dateParts[second] $dateParts[timezone]"); } /** @@ -152,15 +142,14 @@ class DateAndOrTime extends Property { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $parts = DateTimeParser::parseVCardDateTime($this->getValue()); $dateStr = ''; // Year if (!is_null($parts['year'])) { - $dateStr .= $parts['year']; if (!is_null($parts['month'])) { @@ -168,26 +157,21 @@ class DateAndOrTime extends Property { // dash. $dateStr .= '-'; } - } else { - if (!is_null($parts['month']) || !is_null($parts['date'])) { // Inserting two dashes $dateStr .= '--'; } - } // Month if (!is_null($parts['month'])) { - $dateStr .= $parts['month']; if (isset($parts['date'])) { // If month and date are set, we need the separator dash. $dateStr .= '-'; } - } elseif (isset($parts['date'])) { // If the month is empty, and a date is set, we need a 'empty // dash' @@ -199,7 +183,6 @@ class DateAndOrTime extends Property { $dateStr .= $parts['date']; } - // Early exit if we don't have a time string. if (is_null($parts['hour']) && is_null($parts['minute']) && is_null($parts['second'])) { return [$dateStr]; @@ -209,13 +192,11 @@ class DateAndOrTime extends Property { // Hour if (!is_null($parts['hour'])) { - $dateStr .= $parts['hour']; if (!is_null($parts['minute'])) { $dateStr .= ':'; } - } else { // We know either minute or second _must_ be set, so we insert a // dash for an empty value. @@ -224,13 +205,11 @@ class DateAndOrTime extends Property { // Minute if (!is_null($parts['minute'])) { - $dateStr .= $parts['minute']; if (!is_null($parts['second'])) { $dateStr .= ':'; } - } elseif (isset($parts['second'])) { // Dash for empty minute $dateStr .= '-'; @@ -247,30 +226,27 @@ class DateAndOrTime extends Property { } return [$dateStr]; - } /** * 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()); $parts = DateTimeParser::parseVCardDateAndOrTime($this->getValue()); $value = ''; // $d = defined - $d = function($part) use ($parts) { + $d = function ($part) use ($parts) { return !is_null($parts[$part]); }; // $r = read - $r = function($part) use ($parts) { + $r = function ($part) use ($parts) { return $parts[$part]; }; @@ -282,31 +258,29 @@ class DateAndOrTime extends Property { // } if (($d('year') || $d('month') || $d('date')) && (!$d('hour') && !$d('minute') && !$d('second') && !$d('timezone'))) { - if ($d('year') && $d('month') && $d('date')) { - $value .= $r('year') . $r('month') . $r('date'); + $value .= $r('year').$r('month').$r('date'); } elseif ($d('year') && $d('month') && !$d('date')) { - $value .= $r('year') . '-' . $r('month'); + $value .= $r('year').'-'.$r('month'); } elseif (!$d('year') && $d('month')) { - $value .= '--' . $r('month') . $r('date'); + $value .= '--'.$r('month').$r('date'); } elseif (!$d('year') && !$d('month') && $d('date')) { - $value .= '---' . $r('date'); + $value .= '---'.$r('date'); } - // # 4.3.2 + // # 4.3.2 // value-time = element time { // xsd:string { pattern = "(\d\d(\d\d(\d\d)?)?|-\d\d(\d\d?)|--\d\d)" // ~ "(Z|[+\-]\d\d(\d\d)?)?" } // } } elseif ((!$d('year') && !$d('month') && !$d('date')) && ($d('hour') || $d('minute') || $d('second'))) { - if ($d('hour')) { - $value .= $r('hour') . $r('minute') . $r('second'); + $value .= $r('hour').$r('minute').$r('second'); } elseif ($d('minute')) { - $value .= '-' . $r('minute') . $r('second'); + $value .= '-'.$r('minute').$r('second'); } elseif ($d('second')) { - $value .= '--' . $r('second'); + $value .= '--'.$r('second'); } $value .= $r('timezone'); @@ -317,22 +291,19 @@ class DateAndOrTime extends Property { // ~ "(Z|[+\-]\d\d(\d\d)?)?" } // } } elseif ($d('date') && $d('hour')) { - if ($d('year') && $d('month') && $d('date')) { - $value .= $r('year') . $r('month') . $r('date'); + $value .= $r('year').$r('month').$r('date'); } elseif (!$d('year') && $d('month') && $d('date')) { - $value .= '--' . $r('month') . $r('date'); + $value .= '--'.$r('month').$r('date'); } elseif (!$d('year') && !$d('month') && $d('date')) { - $value .= '---' . $r('date'); + $value .= '---'.$r('date'); } - $value .= 'T' . $r('hour') . $r('minute') . $r('second') . + $value .= 'T'.$r('hour').$r('minute').$r('second'). $r('timezone'); - } $writer->writeElement($valueType, $value); - } /** @@ -342,13 +313,10 @@ class DateAndOrTime 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); - } /** @@ -356,10 +324,9 @@ class DateAndOrTime extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return implode($this->delimiter, $this->getParts()); - } /** @@ -384,8 +351,8 @@ class DateAndOrTime extends Property { * * @return array */ - function validate($options = 0) { - + public function validate($options = 0) + { $messages = parent::validate($options); $value = $this->getValue(); @@ -393,13 +360,12 @@ class DateAndOrTime extends Property { DateTimeParser::parseVCardDateTime($value); } catch (InvalidDataException $e) { $messages[] = [ - 'level' => 3, - 'message' => 'The supplied value (' . $value . ') is not a correct DATE-AND-OR-TIME property', - 'node' => $this, + 'level' => 3, + 'message' => 'The supplied value ('.$value.') is not a correct DATE-AND-OR-TIME property', + 'node' => $this, ]; } return $messages; - } } diff --git a/vendor/sabre/vobject/lib/Property/VCard/DateTime.php b/vendor/sabre/vobject/lib/Property/VCard/DateTime.php index e7c804ca7..49c1f3555 100644 --- a/vendor/sabre/vobject/lib/Property/VCard/DateTime.php +++ b/vendor/sabre/vobject/lib/Property/VCard/DateTime.php @@ -11,8 +11,8 @@ namespace Sabre\VObject\Property\VCard; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class DateTime extends DateAndOrTime { - +class DateTime extends DateAndOrTime +{ /** * Returns the type of value. * @@ -21,10 +21,8 @@ class DateTime extends DateAndOrTime { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'DATE-TIME'; - } - } diff --git a/vendor/sabre/vobject/lib/Property/VCard/LanguageTag.php b/vendor/sabre/vobject/lib/Property/VCard/LanguageTag.php index aa7e9178d..697273989 100644 --- a/vendor/sabre/vobject/lib/Property/VCard/LanguageTag.php +++ b/vendor/sabre/vobject/lib/Property/VCard/LanguageTag.php @@ -14,8 +14,8 @@ use * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class LanguageTag extends Property { - +class LanguageTag extends Property +{ /** * Sets a raw value coming from a mimedir (iCalendar/vCard) file. * @@ -23,13 +23,10 @@ class LanguageTag 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); - } /** @@ -37,10 +34,9 @@ class LanguageTag extends Property { * * @return string */ - function getRawMimeDirValue() { - + public function getRawMimeDirValue() + { return $this->getValue(); - } /** @@ -51,10 +47,8 @@ class LanguageTag extends Property { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'LANGUAGE-TAG'; - } - } diff --git a/vendor/sabre/vobject/lib/Property/VCard/TimeStamp.php b/vendor/sabre/vobject/lib/Property/VCard/TimeStamp.php index 9d311f99d..fccf2d600 100644 --- a/vendor/sabre/vobject/lib/Property/VCard/TimeStamp.php +++ b/vendor/sabre/vobject/lib/Property/VCard/TimeStamp.php @@ -15,8 +15,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class TimeStamp extends Text { - +class TimeStamp extends Text +{ /** * In case this is a multi-value property. This string will be used as a * delimiter. @@ -33,10 +33,9 @@ class TimeStamp extends Text { * * @return string */ - function getValueType() { - + public function getValueType() + { return 'TIMESTAMP'; - } /** @@ -46,16 +45,16 @@ class TimeStamp extends Text { * * @return array */ - function getJsonValue() { - + public function getJsonValue() + { $parts = DateTimeParser::parseVCardDateTime($this->getValue()); $dateStr = - $parts['year'] . '-' . - $parts['month'] . '-' . - $parts['date'] . 'T' . - $parts['hour'] . ':' . - $parts['minute'] . ':' . + $parts['year'].'-'. + $parts['month'].'-'. + $parts['date'].'T'. + $parts['hour'].':'. + $parts['minute'].':'. $parts['second']; // Timezone @@ -64,23 +63,19 @@ class TimeStamp extends Text { } return [$dateStr]; - } /** * 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) + { // xCard is the only XML and JSON format that has the same date and time // format than vCard. $valueType = strtolower($this->getValueType()); $writer->writeElement($valueType, $this->getValue()); - } } |