diff options
Diffstat (limited to 'vendor/eluceo/ical/src/Eluceo/iCal/Property')
10 files changed, 988 insertions, 0 deletions
diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/Property/ArrayValue.php b/vendor/eluceo/ical/src/Eluceo/iCal/Property/ArrayValue.php new file mode 100644 index 00000000..314787a0 --- /dev/null +++ b/vendor/eluceo/ical/src/Eluceo/iCal/Property/ArrayValue.php @@ -0,0 +1,43 @@ +<?php + +/* + * This file is part of the eluceo/iCal package. + * + * (c) Markus Poerschke <markus@eluceo.de> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Eluceo\iCal\Property; + +use Eluceo\iCal\Util\PropertyValueUtil; + +class ArrayValue implements ValueInterface +{ + /** + * The value. + * + * @var array + */ + protected $values; + + public function __construct(array $values) + { + $this->values = $values; + } + + public function setValues(array $values) + { + $this->values = $values; + + return $this; + } + + public function getEscapedValue() + { + return implode(',', array_map(function ($value) { + return PropertyValueUtil::escapeValue((string) $value); + }, $this->values)); + } +} diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/Property/DateTimeProperty.php b/vendor/eluceo/ical/src/Eluceo/iCal/Property/DateTimeProperty.php new file mode 100644 index 00000000..d0fd495e --- /dev/null +++ b/vendor/eluceo/ical/src/Eluceo/iCal/Property/DateTimeProperty.php @@ -0,0 +1,38 @@ +<?php + +/* + * This file is part of the eluceo/iCal package. + * + * (c) Markus Poerschke <markus@eluceo.de> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Eluceo\iCal\Property; + +use Eluceo\iCal\Property; +use Eluceo\iCal\Util\DateUtil; + +class DateTimeProperty extends Property +{ + /** + * @param string $name + * @param \DateTime $dateTime + * @param bool $noTime + * @param bool $useTimezone + * @param bool $useUtc + */ + public function __construct( + $name, + \DateTime $dateTime = null, + $noTime = false, + $useTimezone = false, + $useUtc = false + ) { + $dateString = DateUtil::getDateString($dateTime, $noTime, $useTimezone, $useUtc); + $params = DateUtil::getDefaultParams($dateTime, $noTime, $useTimezone); + + parent::__construct($name, $dateString, $params); + } +} diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/Property/DateTimesProperty.php b/vendor/eluceo/ical/src/Eluceo/iCal/Property/DateTimesProperty.php new file mode 100644 index 00000000..6242f285 --- /dev/null +++ b/vendor/eluceo/ical/src/Eluceo/iCal/Property/DateTimesProperty.php @@ -0,0 +1,41 @@ +<?php + +/* + * This file is part of the eluceo/iCal package. + * + * (c) Markus Poerschke <markus@eluceo.de> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Eluceo\iCal\Property; + +use Eluceo\iCal\Property; +use Eluceo\iCal\Util\DateUtil; + +class DateTimesProperty extends Property +{ + /** + * @param string $name + * @param \DateTime[] $dateTimes + * @param bool $noTime + * @param bool $useTimezone + * @param bool $useUtc + */ + public function __construct( + $name, + $dateTimes = array(), + $noTime = false, + $useTimezone = false, + $useUtc = false + ) { + $dates = array(); + foreach ($dateTimes as $dateTime) { + $dates[] = DateUtil::getDateString($dateTime, $noTime, $useTimezone, $useUtc); + } + $params = DateUtil::getDefaultParams($dateTime, $noTime, $useTimezone); + + parent::__construct($name, $dates, $params); + } +} diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/Attendees.php b/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/Attendees.php new file mode 100644 index 00000000..dbb36e7d --- /dev/null +++ b/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/Attendees.php @@ -0,0 +1,102 @@ +<?php + +/* + * This file is part of the eluceo/iCal package. + * + * (c) Markus Poerschke <markus@eluceo.de> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Eluceo\iCal\Property\Event; + +use Eluceo\iCal\Property; + +class Attendees extends Property +{ + /** @var Property[] */ + protected $attendees = array(); + + const PROPERTY_NAME = 'ATTENDEES'; + + public function __construct() + { + // Overwrites constructor functionality of Property + } + + /** + * @param $value + * @param array $params + * + * @return $this + */ + public function add($value, $params = array()) + { + $this->attendees[] = new Property('ATTENDEE', $value, $params); + + return $this; + } + + /** + * @param Property[] $value + * + * @return $this + */ + public function setValue($value) + { + $this->attendees = $value; + + return $this; + } + + /** + * @return Property[] + */ + public function getValue() + { + return $this->attendees; + } + + /** + * {@inheritdoc} + */ + public function toLines() + { + $lines = array(); + foreach ($this->attendees as $attendee) { + $lines[] = $attendee->toLine(); + } + + return $lines; + } + + /** + * @param string $name + * @param mixed $value + * + * @throws \BadMethodCallException + */ + public function setParam($name, $value) + { + throw new \BadMethodCallException('Cannot call setParam on Attendees Property'); + } + + /** + * @param $name + * + * @throws \BadMethodCallException + */ + public function getParam($name) + { + throw new \BadMethodCallException('Cannot call getParam on Attendees Property'); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return self::PROPERTY_NAME; + } +} diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/Description.php b/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/Description.php new file mode 100644 index 00000000..b0dbb3c1 --- /dev/null +++ b/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/Description.php @@ -0,0 +1,66 @@ +<?php + +/* + * This file is part of the eluceo/iCal package. + * + * (c) Markus Poerschke <markus@eluceo.de> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Eluceo\iCal\Property\Event; + +use Eluceo\iCal\Property\ValueInterface; +use Eluceo\iCal\Util\PropertyValueUtil; + +/** + * Class Description + * Alows new line charectars to be in the description. + */ +class Description implements ValueInterface +{ + /** + * The value. + * + * @var string + */ + protected $value; + + public function __construct($value) + { + $this->value = $value; + } + + /** + * Return the value of the Property as an escaped string. + * + * Escape values as per RFC 2445. See http://www.kanzaki.com/docs/ical/text.html + * + * @return string + */ + public function getEscapedValue() + { + return PropertyValueUtil::escapeValue((string) $this->value); + } + + /** + * @param string $value + * + * @return $this + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/Organizer.php b/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/Organizer.php new file mode 100644 index 00000000..a91a75d2 --- /dev/null +++ b/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/Organizer.php @@ -0,0 +1,39 @@ +<?php + +/* + * This file is part of the eluceo/iCal package. + * + * (c) Markus Poerschke <markus@eluceo.de> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Eluceo\iCal\Property\Event; + +use Eluceo\iCal\Property; + +/** + * Class Organizer. + */ +class Organizer extends Property +{ + const PROPERTY_NAME = 'ORGANIZER'; + + /** + * @param string $value + * @param array $params + */ + public function __construct($value, $params = array()) + { + parent::__construct(self::PROPERTY_NAME, $value, $params); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return self::PROPERTY_NAME; + } +} diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/RecurrenceId.php b/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/RecurrenceId.php new file mode 100644 index 00000000..2a684dda --- /dev/null +++ b/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/RecurrenceId.php @@ -0,0 +1,130 @@ +<?php + +/* + * This file is part of the eluceo/iCal package. + * + * (c) Markus Poerschke <markus@eluceo.de> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Eluceo\iCal\Property\Event; + +use Eluceo\iCal\ParameterBag; +use Eluceo\iCal\Property; +use Eluceo\iCal\Util\DateUtil; +use Eluceo\iCal\Property\ValueInterface; + +/** + * Implementation of Recurrence Id. + * + * @see http://www.ietf.org/rfc/rfc2445.txt 4.8.4.4 Recurrence ID + */ +class RecurrenceId extends Property +{ + const PROPERTY_NAME = 'RECURRENCE-ID'; + + /** + * The effective range of recurrence instances from the instance + * specified by the recurrence identifier specified by the property. + */ + const RANGE_THISANDPRIOR = 'THISANDPRIOR'; + const RANGE_THISANDFUTURE = 'THISANDFUTURE'; + + /** + * The dateTime to identify a particular instance of a recurring event which is getting modified. + * + * @var \DateTime + */ + protected $dateTime; + + /** + * Specify the effective range of recurrence instances from the instance. + * + * @var string + */ + protected $range; + + public function __construct(\DateTime $dateTime = null) + { + $this->parameterBag = new ParameterBag(); + if (isset($dateTime)) { + $this->dateTime = $dateTime; + } + } + + public function applyTimeSettings($noTime = false, $useTimezone = false, $useUtc = false) + { + $params = DateUtil::getDefaultParams($this->dateTime, $noTime, $useTimezone, $useUtc); + foreach ($params as $name => $value) { + $this->parameterBag->setParam($name, $value); + } + + if ($this->range) { + $this->parameterBag->setParam('RANGE', $this->range); + } + + $this->setValue(DateUtil::getDateString($this->dateTime, $noTime, $useTimezone, $useUtc)); + } + + /** + * @return DateTime + */ + public function getDatetime() + { + return $this->dateTime; + } + + /** + * @param \DateTime $dateTime + * + * @return \Eluceo\iCal\Property\Event\RecurrenceId + */ + public function setDatetime(\DateTime $dateTime) + { + $this->dateTime = $dateTime; + + return $this; + } + + /** + * @return string + */ + public function getRange() + { + return $this->range; + } + + /** + * @param string $range + * + * @return \Eluceo\iCal\Property\Event\RecurrenceId + */ + public function setRange($range) + { + $this->range = $range; + } + + /** + * Get all unfolded lines. + * + * @return array + */ + public function toLines() + { + if (!$this->value instanceof ValueInterface) { + throw new \Exception('The value must implement the ValueInterface. Call RecurrenceId::applyTimeSettings() before adding RecurrenceId.'); + } else { + return parent::toLines(); + } + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return self::PROPERTY_NAME; + } +} diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/RecurrenceRule.php b/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/RecurrenceRule.php new file mode 100644 index 00000000..32533449 --- /dev/null +++ b/vendor/eluceo/ical/src/Eluceo/iCal/Property/Event/RecurrenceRule.php @@ -0,0 +1,444 @@ +<?php + +/* + * This file is part of the eluceo/iCal package. + * + * (c) Markus Poerschke <markus@eluceo.de> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Eluceo\iCal\Property\Event; + +use Eluceo\iCal\Property\ValueInterface; +use Eluceo\iCal\ParameterBag; +use InvalidArgumentException; + +/** + * Implementation of Recurrence Rule. + * + * @see http://www.ietf.org/rfc/rfc2445.txt 3.3.10. Recurrence Rule + */ +class RecurrenceRule implements ValueInterface +{ + const FREQ_YEARLY = 'YEARLY'; + const FREQ_MONTHLY = 'MONTHLY'; + const FREQ_WEEKLY = 'WEEKLY'; + const FREQ_DAILY = 'DAILY'; + + const WEEKDAY_SUNDAY = 'SU'; + const WEEKDAY_MONDAY = 'MO'; + const WEEKDAY_TUESDAY = 'TU'; + const WEEKDAY_WEDNESDAY = 'WE'; + const WEEKDAY_THURSDAY = 'TH'; + const WEEKDAY_FRIDAY = 'FR'; + const WEEKDAY_SATURDAY = 'SA'; + + /** + * The frequency of an Event. + * + * @var string + */ + protected $freq = self::FREQ_YEARLY; + + /** + * @var null|int + */ + protected $interval = 1; + + /** + * @var null|int + */ + protected $count = null; + + /** + * @var null|\DateTime + */ + protected $until = null; + + /** + * @var null|string + */ + protected $wkst; + + /** + * @var null|string + */ + protected $byMonth; + + /** + * @var null|string + */ + protected $byWeekNo; + + /** + * @var null|string + */ + protected $byYearDay; + + /** + * @var null|string + */ + protected $byMonthDay; + + /** + * @var null|string + */ + protected $byDay; + + /** + * @var null|string + */ + protected $byHour; + + /** + * @var null|string + */ + protected $byMinute; + + /** + * @var null|string + */ + protected $bySecond; + + /** + * Return the value of the Property as an escaped string. + * + * Escape values as per RFC 2445. See http://www.kanzaki.com/docs/ical/text.html + * + * @return string + */ + public function getEscapedValue() + { + return $this->buildParameterBag()->toString(); + } + + /** + * @return ParameterBag + */ + protected function buildParameterBag() + { + $parameterBag = new ParameterBag(); + + $parameterBag->setParam('FREQ', $this->freq); + + if (null !== $this->interval) { + $parameterBag->setParam('INTERVAL', $this->interval); + } + + if (null !== $this->count) { + $parameterBag->setParam('COUNT', $this->count); + } + + if (null != $this->until) { + $parameterBag->setParam('UNTIL', $this->until->format('Ymd\THis\Z')); + } + + if (null !== $this->wkst) { + $parameterBag->setParam('WKST', $this->wkst); + } + + if (null !== $this->byMonth) { + $parameterBag->setParam('BYMONTH', $this->byMonth); + } + + if (null !== $this->byWeekNo) { + $parameterBag->setParam('BYWEEKNO', $this->byWeekNo); + } + + if (null !== $this->byYearDay) { + $parameterBag->setParam('BYYEARDAY', $this->byYearDay); + } + + if (null !== $this->byMonthDay) { + $parameterBag->setParam('BYMONTHDAY', $this->byMonthDay); + } + + if (null !== $this->byDay) { + $parameterBag->setParam('BYDAY', $this->byDay); + } + + if (null !== $this->byHour) { + $parameterBag->setParam('BYHOUR', $this->byHour); + } + + if (null !== $this->byMinute) { + $parameterBag->setParam('BYMINUTE', $this->byMinute); + } + + if (null !== $this->bySecond) { + $parameterBag->setParam('BYSECOND', $this->bySecond); + } + + return $parameterBag; + } + + /** + * @param int|null $count + * + * @return $this + */ + public function setCount($count) + { + $this->count = $count; + + return $this; + } + + /** + * @return int|null + */ + public function getCount() + { + return $this->count; + } + + /** + * @param \DateTime|null $until + * + * @return $this + */ + public function setUntil(\DateTime $until = null) + { + $this->until = $until; + + return $this; + } + + /** + * @return \DateTime|null + */ + public function getUntil() + { + return $this->until; + } + + /** + * The FREQ rule part identifies the type of recurrence rule. This + * rule part MUST be specified in the recurrence rule. Valid values + * include. + * + * SECONDLY, to specify repeating events based on an interval of a second or more; + * MINUTELY, to specify repeating events based on an interval of a minute or more; + * HOURLY, to specify repeating events based on an interval of an hour or more; + * DAILY, to specify repeating events based on an interval of a day or more; + * WEEKLY, to specify repeating events based on an interval of a week or more; + * MONTHLY, to specify repeating events based on an interval of a month or more; + * YEARLY, to specify repeating events based on an interval of a year or more. + * + * @param string $freq + * + * @return $this + * + * @throws \InvalidArgumentException + */ + public function setFreq($freq) + { + if (self::FREQ_YEARLY === $freq || self::FREQ_MONTHLY === $freq + || self::FREQ_WEEKLY === $freq + || self::FREQ_DAILY === $freq + ) { + $this->freq = $freq; + } else { + throw new \InvalidArgumentException("The Frequency {$freq} is not supported."); + } + + return $this; + } + + /** + * @return string + */ + public function getFreq() + { + return $this->freq; + } + + /** + * The INTERVAL rule part contains a positive integer representing at + * which intervals the recurrence rule repeats. + * + * @param int|null $interval + * + * @return $this + */ + public function setInterval($interval) + { + $this->interval = $interval; + + return $this; + } + + /** + * @return int|null + */ + public function getInterval() + { + return $this->interval; + } + + /** + * The WKST rule part specifies the day on which the workweek starts. + * Valid values are MO, TU, WE, TH, FR, SA, and SU. + * + * @param string $value + * + * @return $this + */ + public function setWkst($value) + { + $this->wkst = $value; + + return $this; + } + + /** + * The BYMONTH rule part specifies a COMMA-separated list of months of the year. + * Valid values are 1 to 12. + * + * @param int $month + * + * @throws InvalidArgumentException + * + * @return $this + */ + public function setByMonth($month) + { + if (!is_integer($month) || $month < 0 || $month > 12) { + throw new InvalidArgumentException('Invalid value for BYMONTH'); + } + + $this->byMonth = $month; + + return $this; + } + + /** + * The BYWEEKNO rule part specifies a COMMA-separated list of ordinals specifying weeks of the year. + * Valid values are 1 to 53 or -53 to -1. + * + * @param int $value + * + * @return $this + */ + public function setByWeekNo($value) + { + $this->byWeekNo = $value; + + return $this; + } + + /** + * The BYYEARDAY rule part specifies a COMMA-separated list of days of the year. + * Valid values are 1 to 366 or -366 to -1. + * + * @param int $day + * + * @return $this + */ + public function setByYearDay($day) + { + $this->byYearDay = $day; + + return $this; + } + + /** + * The BYMONTHDAY rule part specifies a COMMA-separated list of days of the month. + * Valid values are 1 to 31 or -31 to -1. + * + * @param int $day + * + * @return $this + */ + public function setByMonthDay($day) + { + $this->byMonthDay = $day; + + return $this; + } + + /** + * The BYDAY rule part specifies a COMMA-separated list of days of the week;. + * + * SU indicates Sunday; MO indicates Monday; TU indicates Tuesday; + * WE indicates Wednesday; TH indicates Thursday; FR indicates Friday; and SA indicates Saturday. + * + * Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer. + * If present, this indicates the nth occurrence of a specific day within the MONTHLY or YEARLY "RRULE". + * + * @param string $day + * + * @return $this + */ + public function setByDay($day) + { + $this->byDay = $day; + + return $this; + } + + /** + * The BYHOUR rule part specifies a COMMA-separated list of hours of the day. + * Valid values are 0 to 23. + * + * @param int $value + * + * @return $this + * + * @throws \InvalidArgumentException + */ + public function setByHour($value) + { + if (!is_integer($value) || $value < 0 || $value > 23) { + throw new \InvalidArgumentException('Invalid value for BYHOUR'); + } + + $this->byHour = $value; + + return $this; + } + + /** + * The BYMINUTE rule part specifies a COMMA-separated list of minutes within an hour. + * Valid values are 0 to 59. + * + * @param int $value + * + * @return $this + * + * @throws \InvalidArgumentException + */ + public function setByMinute($value) + { + if (!is_integer($value) || $value < 0 || $value > 59) { + throw new \InvalidArgumentException('Invalid value for BYMINUTE'); + } + + $this->byMinute = $value; + + return $this; + } + + /** + * The BYSECOND rule part specifies a COMMA-separated list of seconds within a minute. + * Valid values are 0 to 60. + * + * @param int $value + * + * @return $this + * + * @throws \InvalidArgumentException + */ + public function setBySecond($value) + { + if (!is_integer($value) || $value < 0 || $value > 60) { + throw new \InvalidArgumentException('Invalid value for BYSECOND'); + } + + $this->bySecond = $value; + + return $this; + } +} diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/Property/StringValue.php b/vendor/eluceo/ical/src/Eluceo/iCal/Property/StringValue.php new file mode 100644 index 00000000..4995723b --- /dev/null +++ b/vendor/eluceo/ical/src/Eluceo/iCal/Property/StringValue.php @@ -0,0 +1,61 @@ +<?php + +/* + * This file is part of the eluceo/iCal package. + * + * (c) Markus Poerschke <markus@eluceo.de> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Eluceo\iCal\Property; + +use Eluceo\iCal\Util\PropertyValueUtil; + +class StringValue implements ValueInterface +{ + /** + * The value. + * + * @var string + */ + protected $value; + + public function __construct($value) + { + $this->value = $value; + } + + /** + * Return the value of the Property as an escaped string. + * + * Escape values as per RFC 2445. See http://www.kanzaki.com/docs/ical/text.html + * + * @return string + */ + public function getEscapedValue() + { + return PropertyValueUtil::escapeValue((string) $this->value); + } + + /** + * @param string $value + * + * @return $this + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/vendor/eluceo/ical/src/Eluceo/iCal/Property/ValueInterface.php b/vendor/eluceo/ical/src/Eluceo/iCal/Property/ValueInterface.php new file mode 100644 index 00000000..cc3d885c --- /dev/null +++ b/vendor/eluceo/ical/src/Eluceo/iCal/Property/ValueInterface.php @@ -0,0 +1,24 @@ +<?php + +/* + * This file is part of the eluceo/iCal package. + * + * (c) Markus Poerschke <markus@eluceo.de> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Eluceo\iCal\Property; + +interface ValueInterface +{ + /** + * Return the value of the Property as an escaped string. + * + * Escape values as per RFC 2445. See http://www.kanzaki.com/docs/ical/text.html + * + * @return string + */ + public function getEscapedValue(); +} |