aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php')
-rw-r--r--vendor/sabre/vobject/lib/BirthdayCalendarGenerator.php51
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;
-
}
-
}