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/BirthdayCalendarGenerator.php | |
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/BirthdayCalendarGenerator.php')
-rw-r--r-- | vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php | 51 |
1 files changed, 16 insertions, 35 deletions
diff --git a/vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php b/vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php index 553912249..fade50e16 100644 --- a/vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php +++ b/vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php @@ -11,8 +11,8 @@ use Sabre\VObject\Component\VCalendar; * @author Dominik Tobschall (http://tobschall.de/) * @license http://sabre.io/license/ Modified BSD License */ -class BirthdayCalendarGenerator { - +class BirthdayCalendarGenerator +{ /** * Input objects. * @@ -41,12 +41,11 @@ class BirthdayCalendarGenerator { * * @param mixed $objects */ - function __construct($objects = null) { - + public function __construct($objects = null) + { if ($objects) { $this->setObjects($objects); } - } /** @@ -56,52 +55,38 @@ class BirthdayCalendarGenerator { * It's also possible to supply an array of strings or objects. * * @param mixed $objects - * - * @return void */ - function setObjects($objects) { - + public function setObjects($objects) + { if (!is_array($objects)) { $objects = [$objects]; } $this->objects = []; foreach ($objects as $object) { - if (is_string($object)) { - $vObj = Reader::read($object); if (!$vObj instanceof Component\VCard) { throw new \InvalidArgumentException('String could not be parsed as \\Sabre\\VObject\\Component\\VCard by setObjects'); } $this->objects[] = $vObj; - } elseif ($object instanceof Component\VCard) { - $this->objects[] = $object; - } else { - throw new \InvalidArgumentException('You can only pass strings or \\Sabre\\VObject\\Component\\VCard arguments to setObjects'); - } - } - } /** - * Sets the output format for the SUMMARY + * Sets the output format for the SUMMARY. * * @param string $format - * - * @return void */ - function setFormat($format) { - + public function setFormat($format) + { $this->format = $format; - } /** @@ -109,12 +94,11 @@ class BirthdayCalendarGenerator { * * @return Component/VCalendar */ - function getResult() { - + public function getResult() + { $calendar = new VCalendar(); foreach ($this->objects as $object) { - // Skip if there is no BDAY property. if (!$object->select('BDAY')) { continue; @@ -152,7 +136,7 @@ class BirthdayCalendarGenerator { $unknownYear = false; if (!$dateParts['year']) { - $object->BDAY = self::DEFAULT_YEAR . '-' . $dateParts['month'] . '-' . $dateParts['date']; + $object->BDAY = self::DEFAULT_YEAR.'-'.$dateParts['month'].'-'.$dateParts['date']; $unknownYear = true; } @@ -161,8 +145,8 @@ class BirthdayCalendarGenerator { $event = $calendar->add('VEVENT', [ 'SUMMARY' => sprintf($this->format, $object->FN->getValue()), 'DTSTART' => new \DateTime($object->BDAY->getValue()), - 'RRULE' => 'FREQ=YEARLY', - 'TRANSP' => 'TRANSPARENT', + 'RRULE' => 'FREQ=YEARLY', + 'TRANSP' => 'TRANSPARENT', ]); // add VALUE=date @@ -172,20 +156,17 @@ class BirthdayCalendarGenerator { if ($unknownYear) { $event->add('X-SABRE-BDAY', 'BDAY', [ 'X-SABRE-VCARD-UID' => $object->UID->getValue(), - 'X-SABRE-VCARD-FN' => $object->FN->getValue(), + 'X-SABRE-VCARD-FN' => $object->FN->getValue(), 'X-SABRE-OMIT-YEAR' => self::DEFAULT_YEAR, ]); } else { $event->add('X-SABRE-BDAY', 'BDAY', [ 'X-SABRE-VCARD-UID' => $object->UID->getValue(), - 'X-SABRE-VCARD-FN' => $object->FN->getValue(), + 'X-SABRE-VCARD-FN' => $object->FN->getValue(), ]); } - } return $calendar; - } - } |