diff options
author | Mario <mario@mariovavti.com> | 2019-04-25 11:24:09 +0200 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-04-25 11:24:09 +0200 |
commit | f1c07977809ce3221286d53e99f0d91145b1166f (patch) | |
tree | 4c067a3b701ea56f10070c386b26a30f93666eb0 /vendor/sabre/vobject/lib/Property/VCard | |
parent | 701167bc125700efb3e6ce759b85bcb4d36ee42e (diff) | |
download | volse-hubzilla-f1c07977809ce3221286d53e99f0d91145b1166f.tar.gz volse-hubzilla-f1c07977809ce3221286d53e99f0d91145b1166f.tar.bz2 volse-hubzilla-f1c07977809ce3221286d53e99f0d91145b1166f.zip |
Revert "update composer libs"
This reverts commit e779335d060b3a51d6a144d23af4097ae6801473
Diffstat (limited to 'vendor/sabre/vobject/lib/Property/VCard')
5 files changed, 128 insertions, 76 deletions
diff --git a/vendor/sabre/vobject/lib/Property/VCard/Date.php b/vendor/sabre/vobject/lib/Property/VCard/Date.php index a018ccbb8..1ef6dff34 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,18 +21,23 @@ class Date extends DateAndOrTime * * @return string */ - public function getValueType() - { + function getValueType() { + return 'DATE'; + } /** * Sets the property as a DateTime object. * * @param \DateTimeInterface $dt + * + * @return void */ - public function setDateTime(\DateTimeInterface $dt) - { + 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 b7e17492a..3b4ae3bb5 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 string|null + * @var null|string */ public $delimiter = null; @@ -36,9 +36,10 @@ class DateAndOrTime extends Property * * @return string */ - public function getValueType() - { + function getValueType() { + return 'DATE-AND-OR-TIME'; + } /** @@ -47,9 +48,11 @@ class DateAndOrTime extends Property * You may also specify DateTimeInterface objects here. * * @param array $parts + * + * @return void */ - public function setParts(array $parts) - { + function setParts(array $parts) { + if (count($parts) > 1) { throw new \InvalidArgumentException('Only one value allowed'); } @@ -58,6 +61,7 @@ class DateAndOrTime extends Property } else { parent::setParts($parts); } + } /** @@ -68,23 +72,28 @@ class DateAndOrTime extends Property * Instead of strings, you may also use DateTimeInterface here. * * @param string|array|DateTimeInterface $value + * + * @return void */ - public function setValue($value) - { + 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 */ - public function setDateTime(DateTimeInterface $dt) - { + function setDateTime(DateTimeInterface $dt) { + $tz = $dt->getTimeZone(); $isUtc = in_array($tz->getName(), ['UTC', 'GMT', 'Z']); @@ -96,6 +105,7 @@ class DateAndOrTime extends Property } $this->value = $value; + } /** @@ -114,12 +124,12 @@ class DateAndOrTime extends Property * * @return DateTimeImmutable */ - public function getDateTime() - { + function getDateTime() { + $now = new DateTime(); - $tzFormat = 0 === $now->getTimezone()->getOffset($now) ? '\\Z' : 'O'; - $nowParts = DateTimeParser::parseVCardDateTime($now->format('Ymd\\This'.$tzFormat)); + $tzFormat = $now->getTimezone()->getOffset($now) === 0 ? '\\Z' : 'O'; + $nowParts = DateTimeParser::parseVCardDateTime($now->format('Ymd\\This' . $tzFormat)); $dateParts = DateTimeParser::parseVCardDateTime($this->getValue()); @@ -131,8 +141,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]"); + } /** @@ -142,14 +152,15 @@ class DateAndOrTime extends Property * * @return array */ - public function getJsonValue() - { + function getJsonValue() { + $parts = DateTimeParser::parseVCardDateTime($this->getValue()); $dateStr = ''; // Year if (!is_null($parts['year'])) { + $dateStr .= $parts['year']; if (!is_null($parts['month'])) { @@ -157,21 +168,26 @@ 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' @@ -183,6 +199,7 @@ 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]; @@ -192,11 +209,13 @@ 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. @@ -205,11 +224,13 @@ 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 .= '-'; @@ -226,27 +247,30 @@ 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 + * @param Xml\Writer $writer XML writer. + * + * @return void */ - 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]; }; @@ -258,29 +282,31 @@ 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'); @@ -291,19 +317,22 @@ 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); + } /** @@ -313,10 +342,13 @@ class DateAndOrTime extends Property * not yet done, but parameters are not included. * * @param string $val + * + * @return void */ - public function setRawMimeDirValue($val) - { + function setRawMimeDirValue($val) { + $this->setValue($val); + } /** @@ -324,9 +356,10 @@ class DateAndOrTime extends Property * * @return string */ - public function getRawMimeDirValue() - { + function getRawMimeDirValue() { + return implode($this->delimiter, $this->getParts()); + } /** @@ -351,8 +384,8 @@ class DateAndOrTime extends Property * * @return array */ - public function validate($options = 0) - { + function validate($options = 0) { + $messages = parent::validate($options); $value = $this->getValue(); @@ -360,12 +393,13 @@ 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 49c1f3555..e7c804ca7 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,8 +21,10 @@ class DateTime extends DateAndOrTime * * @return string */ - public function getValueType() - { + 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 697273989..aa7e9178d 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,10 +23,13 @@ class LanguageTag extends Property * not yet done, but parameters are not included. * * @param string $val + * + * @return void */ - public function setRawMimeDirValue($val) - { + function setRawMimeDirValue($val) { + $this->setValue($val); + } /** @@ -34,9 +37,10 @@ class LanguageTag extends Property * * @return string */ - public function getRawMimeDirValue() - { + function getRawMimeDirValue() { + return $this->getValue(); + } /** @@ -47,8 +51,10 @@ class LanguageTag extends Property * * @return string */ - public function getValueType() - { + 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 fccf2d600..9d311f99d 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,9 +33,10 @@ class TimeStamp extends Text * * @return string */ - public function getValueType() - { + function getValueType() { + return 'TIMESTAMP'; + } /** @@ -45,16 +46,16 @@ class TimeStamp extends Text * * @return array */ - public function getJsonValue() - { + 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 @@ -63,19 +64,23 @@ 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 + * @param Xml\Writer $writer XML writer. + * + * @return void */ - 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()); + } } |