Fix various compatibility issues with PHP 8
This commit is contained in:
committed by
Frédéric Guillot
parent
f5bb55bdb8
commit
4bf3b0d459
39
libs/ical/Property/Event/Attachment.php
Normal file
39
libs/ical/Property/Event/Attachment.php
Normal file
@@ -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 Attachment.
|
||||
*/
|
||||
class Attachment extends Property
|
||||
{
|
||||
/**
|
||||
* @param string $value
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct($value, $params = [])
|
||||
{
|
||||
parent::__construct('ATTACH', $value, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $url
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->setValue($url);
|
||||
}
|
||||
}
|
||||
95
libs/ical/Property/Event/Attendees.php
Normal file
95
libs/ical/Property/Event/Attendees.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?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 = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'ATTENDEES';
|
||||
// prevent super constructor to be called
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param array $params
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function add($value, $params = [])
|
||||
{
|
||||
$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 = [];
|
||||
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');
|
||||
}
|
||||
}
|
||||
82
libs/ical/Property/Event/Geo.php
Normal file
82
libs/ical/Property/Event/Geo.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* GEO property.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.1.6
|
||||
*/
|
||||
class Geo extends Property
|
||||
{
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $latitude;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $longitude;
|
||||
|
||||
public function __construct(float $latitude, float $longitude)
|
||||
{
|
||||
$this->latitude = $latitude;
|
||||
$this->longitude = $longitude;
|
||||
|
||||
if ($this->latitude < -90 || $this->latitude > 90) {
|
||||
throw new \InvalidArgumentException("The geographical latitude must be a value between -90 and 90 degrees. '{$this->latitude}' was given.");
|
||||
}
|
||||
|
||||
if ($this->longitude < -180 || $this->longitude > 180) {
|
||||
throw new \InvalidArgumentException("The geographical longitude must be a value between -180 and 180 degrees. '{$this->longitude}' was given.");
|
||||
}
|
||||
|
||||
parent::__construct('GEO', new Property\RawStringValue($this->getGeoLocationAsString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is used to allow backwards compatibility for Event::setLocation
|
||||
*
|
||||
* @return Geo
|
||||
*/
|
||||
public static function fromString(string $geoLocationString): self
|
||||
{
|
||||
$geoLocationString = str_replace(',', ';', $geoLocationString);
|
||||
$geoLocationString = str_replace('GEO:', '', $geoLocationString);
|
||||
$parts = explode(';', $geoLocationString);
|
||||
|
||||
return new static((float) $parts[0], (float) $parts[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the coordinates as a string.
|
||||
*
|
||||
* @example 37.386013;-122.082932
|
||||
*/
|
||||
public function getGeoLocationAsString(string $separator = ';'): string
|
||||
{
|
||||
return number_format($this->latitude, 6) . $separator . number_format($this->longitude, 6);
|
||||
}
|
||||
|
||||
public function getLatitude(): float
|
||||
{
|
||||
return $this->latitude;
|
||||
}
|
||||
|
||||
public function getLongitude(): float
|
||||
{
|
||||
return $this->longitude;
|
||||
}
|
||||
}
|
||||
29
libs/ical/Property/Event/Organizer.php
Normal file
29
libs/ical/Property/Event/Organizer.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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
|
||||
{
|
||||
/**
|
||||
* @param string $value
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct($value, $params = [])
|
||||
{
|
||||
parent::__construct('ORGANIZER', $value, $params);
|
||||
}
|
||||
}
|
||||
121
libs/ical/Property/Event/RecurrenceId.php
Normal file
121
libs/ical/Property/Event/RecurrenceId.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?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\Property\ValueInterface;
|
||||
use Eluceo\iCal\Util\DateUtil;
|
||||
|
||||
/**
|
||||
* Implementation of Recurrence Id.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.4.4
|
||||
*/
|
||||
class RecurrenceId extends Property
|
||||
{
|
||||
/**
|
||||
* 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 \DateTimeInterface
|
||||
*/
|
||||
protected $dateTime;
|
||||
|
||||
/**
|
||||
* Specify the effective range of recurrence instances from the instance.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $range;
|
||||
|
||||
public function __construct(\DateTimeInterface $dateTime = null)
|
||||
{
|
||||
$this->name = 'RECURRENCE-ID';
|
||||
$this->parameterBag = new ParameterBag();
|
||||
if (isset($dateTime)) {
|
||||
$this->dateTime = $dateTime;
|
||||
}
|
||||
}
|
||||
|
||||
public function applyTimeSettings($noTime = false, $useTimezone = false, $useUtc = false, $timezoneString = '')
|
||||
{
|
||||
$params = DateUtil::getDefaultParams($this->dateTime, $noTime, $useTimezone, $timezoneString);
|
||||
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 \DateTimeInterface
|
||||
*/
|
||||
public function getDatetime()
|
||||
{
|
||||
return $this->dateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Eluceo\iCal\Property\Event\RecurrenceId
|
||||
*/
|
||||
public function setDatetime(\DateTimeInterface $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;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
546
libs/ical/Property/Event/RecurrenceRule.php
Normal file
546
libs/ical/Property/Event/RecurrenceRule.php
Normal file
@@ -0,0 +1,546 @@
|
||||
<?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\ValueInterface;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Implementation of Recurrence Rule.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.5.3
|
||||
*/
|
||||
class RecurrenceRule implements ValueInterface
|
||||
{
|
||||
const FREQ_YEARLY = 'YEARLY';
|
||||
const FREQ_MONTHLY = 'MONTHLY';
|
||||
const FREQ_WEEKLY = 'WEEKLY';
|
||||
const FREQ_DAILY = 'DAILY';
|
||||
const FREQ_HOURLY = 'HOURLY';
|
||||
const FREQ_MINUTELY = 'MINUTELY';
|
||||
const FREQ_SECONDLY = 'SECONDLY';
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* BYSETPOS must require use of other BY*.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $canUseBySetPos = false;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
protected $interval = 1;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
protected $count = null;
|
||||
|
||||
/**
|
||||
* @var \DateTimeInterface|null
|
||||
*/
|
||||
protected $until = null;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $wkst;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
protected $bySetPos = null;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byMonth;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byWeekNo;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byYearDay;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byMonthDay;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byDay;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byHour;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byMinute;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $bySecond;
|
||||
|
||||
public function getEscapedValue(): string
|
||||
{
|
||||
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->bySetPos && $this->canUseBySetPos) {
|
||||
$parameterBag->setParam('BYSETPOS', $this->bySetPos);
|
||||
}
|
||||
|
||||
if (null !== $this->byMonth) {
|
||||
$parameterBag->setParam('BYMONTH', explode(',', $this->byMonth));
|
||||
}
|
||||
|
||||
if (null !== $this->byWeekNo) {
|
||||
$parameterBag->setParam('BYWEEKNO', explode(',', $this->byWeekNo));
|
||||
}
|
||||
|
||||
if (null !== $this->byYearDay) {
|
||||
$parameterBag->setParam('BYYEARDAY', explode(',', $this->byYearDay));
|
||||
}
|
||||
|
||||
if (null !== $this->byMonthDay) {
|
||||
$parameterBag->setParam('BYMONTHDAY', explode(',', $this->byMonthDay));
|
||||
}
|
||||
|
||||
if (null !== $this->byDay) {
|
||||
$parameterBag->setParam('BYDAY', explode(',', $this->byDay));
|
||||
}
|
||||
|
||||
if (null !== $this->byHour) {
|
||||
$parameterBag->setParam('BYHOUR', explode(',', $this->byHour));
|
||||
}
|
||||
|
||||
if (null !== $this->byMinute) {
|
||||
$parameterBag->setParam('BYMINUTE', explode(',', $this->byMinute));
|
||||
}
|
||||
|
||||
if (null !== $this->bySecond) {
|
||||
$parameterBag->setParam('BYSECOND', explode(',', $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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setUntil(\DateTimeInterface $until = null)
|
||||
{
|
||||
$this->until = $until;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTimeInterface|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 (@constant('static::FREQ_' . $freq) !== null) {
|
||||
$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 BYSETPOS filters one interval of events by the specified position.
|
||||
* A positive position will start from the beginning and go forward while
|
||||
* a negative position will start at the end and move backward.
|
||||
*
|
||||
* Valid values are a comma separated string or an array of integers
|
||||
* from 1 to 366 or negative integers from -1 to -366.
|
||||
*
|
||||
* @param int|string|array|null $value
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBySetPos($value)
|
||||
{
|
||||
if (null === $value) {
|
||||
$this->bySetPos = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!(is_string($value) || is_array($value) || is_int($value))) {
|
||||
throw new InvalidArgumentException('Invalid value for BYSETPOS');
|
||||
}
|
||||
|
||||
$list = $value;
|
||||
|
||||
if (is_int($value)) {
|
||||
if ($value === 0 || $value < -366 || $value > 366) {
|
||||
throw new InvalidArgumentException('Invalid value for BYSETPOS');
|
||||
}
|
||||
$this->bySetPos = [$value];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
$list = explode(',', $value);
|
||||
}
|
||||
|
||||
$output = [];
|
||||
|
||||
foreach ($list as $item) {
|
||||
if (is_string($item)) {
|
||||
if (!preg_match('/^ *-?[0-9]* *$/', $item)) {
|
||||
throw new InvalidArgumentException('Invalid value for BYSETPOS');
|
||||
}
|
||||
$item = intval($item);
|
||||
}
|
||||
|
||||
if (!is_int($item) || $item === 0 || $item < -366 || $item > 366) {
|
||||
throw new InvalidArgumentException('Invalid value for BYSETPOS');
|
||||
}
|
||||
|
||||
$output[] = $item;
|
||||
}
|
||||
|
||||
$this->bySetPos = $output;
|
||||
|
||||
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;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
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
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setByWeekNo($value)
|
||||
{
|
||||
if (!is_integer($value) || $value > 53 || $value < -53 || $value === 0) {
|
||||
throw new InvalidArgumentException('Invalid value for BYWEEKNO');
|
||||
}
|
||||
|
||||
$this->byWeekNo = $value;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
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
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setByYearDay($day)
|
||||
{
|
||||
if (!is_integer($day) || $day > 366 || $day < -366 || $day === 0) {
|
||||
throw new InvalidArgumentException('Invalid value for BYYEARDAY');
|
||||
}
|
||||
|
||||
$this->byYearDay = $day;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
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
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setByMonthDay($day)
|
||||
{
|
||||
if (!is_integer($day) || $day > 31 || $day < -31 || $day === 0) {
|
||||
throw new InvalidArgumentException('Invalid value for BYMONTHDAY');
|
||||
}
|
||||
|
||||
$this->byMonthDay = $day;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
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".
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setByDay(string $day)
|
||||
{
|
||||
$this->byDay = $day;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
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;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
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;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
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;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user