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/VCard | |
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/VCard')
5 files changed, 76 insertions, 128 deletions
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()); - } } |