Update vendor folder
This commit is contained in:
3
vendor/eluceo/ical/.gitignore
vendored
3
vendor/eluceo/ical/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
vendor
|
||||
composer.lock
|
||||
bin
|
||||
26
vendor/eluceo/ical/.php_cs
vendored
26
vendor/eluceo/ical/.php_cs
vendored
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader(<<<EOF
|
||||
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.
|
||||
EOF
|
||||
);
|
||||
|
||||
$finder = Symfony\CS\Finder\DefaultFinder::create();
|
||||
$finder->in(__DIR__ . '/src');
|
||||
|
||||
return Symfony\CS\Config\Config::create()
|
||||
->fixers(array(
|
||||
'header_comment',
|
||||
'concat_with_spaces',
|
||||
'align_equals',
|
||||
'align_double_arrow',
|
||||
'unused_use',
|
||||
'long_array_syntax',
|
||||
))
|
||||
->finder($finder)
|
||||
;
|
||||
20
vendor/eluceo/ical/.scrutinizer.yml
vendored
20
vendor/eluceo/ical/.scrutinizer.yml
vendored
@@ -1,20 +0,0 @@
|
||||
filter:
|
||||
excluded_paths:
|
||||
- tests/*
|
||||
|
||||
tools:
|
||||
php_cs_fixer: true
|
||||
php_code_sniffer:
|
||||
config:
|
||||
standard: PSR2
|
||||
php_mess_detector: true
|
||||
php_analyzer: true
|
||||
sensiolabs_security_checker: true
|
||||
external_code_coverage:
|
||||
timeout: 300
|
||||
runs: 1
|
||||
|
||||
checks:
|
||||
php:
|
||||
code_rating: true
|
||||
duplication: true
|
||||
19
vendor/eluceo/ical/.travis.yml
vendored
19
vendor/eluceo/ical/.travis.yml
vendored
@@ -1,19 +0,0 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
|
||||
before_script:
|
||||
- composer self-update
|
||||
- composer install
|
||||
|
||||
script: ./bin/phpunit --coverage-clover=coverage.clover
|
||||
|
||||
after_script:
|
||||
- wget https://scrutinizer-ci.com/ocular.phar
|
||||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
||||
31
vendor/eluceo/ical/CHANGELOG.md
vendored
31
vendor/eluceo/ical/CHANGELOG.md
vendored
@@ -1,31 +0,0 @@
|
||||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [0.10.1] - 2016-05-09
|
||||
### Fixed
|
||||
- Problem with GEO property when importing into Google Calendar [#74](https://github.com/markuspoerschke/iCal/pull/74)
|
||||
|
||||
## [0.10.0] - 2016-04-26
|
||||
### Changed
|
||||
- Use 'escapeValue' to escape the new line character. [#60](https://github.com/markuspoerschke/iCal/pull/60)
|
||||
- Order components by type when building ical file. [#65](https://github.com/markuspoerschke/iCal/pull/65)
|
||||
|
||||
### Added
|
||||
- X-ALT-DESC for HTML types with new descriptionHTML field. [#55](https://github.com/markuspoerschke/iCal/pull/55)
|
||||
- Added a property and setter for calendar color. [#68](https://github.com/markuspoerschke/iCal/pull/68)
|
||||
- Write also GEO property if geo location is given. [#66](https://github.com/markuspoerschke/iCal/pull/66)
|
||||
|
||||
## [0.9.0] - 2015-11-13
|
||||
### Added
|
||||
- CHANGELOG.md based on [’Keep a CHANGELOG’](https://github.com/olivierlacan/keep-a-changelog)
|
||||
- Support event properties EXDATE and RECURRENCE-ID [#50](https://github.com/markuspoerschke/iCal/pull/53)
|
||||
|
||||
### Changed
|
||||
- Allow new lines in event descriptions [#53](https://github.com/markuspoerschke/iCal/pull/53)
|
||||
- **Breaking Change:** Changed signature of the ```Event::setOrganizer``` method. Now there is is only one parameter that must be an instance of ```Property\Organizer```.
|
||||
- Updated install section in README.md [#54](https://github.com/markuspoerschke/iCal/pull/53)
|
||||
|
||||
[Unreleased]: https://github.com/markuspoerschke/iCal/compare/0.10.1...HEAD
|
||||
[0.10.1]: https://github.com/markuspoerschke/iCal/compare/0.10.0...0.10.1
|
||||
[0.10.0]: https://github.com/markuspoerschke/iCal/compare/0.9.0...0.10.0
|
||||
[0.9.0]: https://github.com/markuspoerschke/iCal/compare/0.8.0...0.9.0
|
||||
2
vendor/eluceo/ical/LICENSE
vendored
2
vendor/eluceo/ical/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2012-2015 Markus Poerschke
|
||||
Copyright (c) 2012-2019 Markus Poerschke
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
158
vendor/eluceo/ical/README.md
vendored
158
vendor/eluceo/ical/README.md
vendored
@@ -1,158 +0,0 @@
|
||||
# eluceo — iCal
|
||||
|
||||
[](https://scrutinizer-ci.com/g/markuspoerschke/iCal/?branch=master) [](https://scrutinizer-ci.com/g/markuspoerschke/iCal/?branch=master) [](https://travis-ci.org/markuspoerschke/iCal)
|
||||
|
||||
This package offers a abstraction layer for creating iCalendars. The output will
|
||||
follow [RFC 5545](http://www.ietf.org/rfc/rfc5545.txt) as best as possible.
|
||||
|
||||
The following components are supported at this time:
|
||||
|
||||
* VCALENDAR
|
||||
* VEVENT
|
||||
* VALARM
|
||||
* VTIMEZONE
|
||||
|
||||
## Installation
|
||||
|
||||
You can install this package by using [Composer](http://getcomposer.org), running this command:
|
||||
|
||||
```sh
|
||||
composer require eluceo/ical
|
||||
```
|
||||
Link to Packagist: https://packagist.org/packages/eluceo/ical
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Usage
|
||||
|
||||
#### 1. Create a Calendar object
|
||||
|
||||
```PHP
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
```
|
||||
|
||||
#### 2. Create an Event object
|
||||
|
||||
```PHP
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
```
|
||||
|
||||
#### 3. Add your information to the Event
|
||||
|
||||
```PHP
|
||||
$vEvent
|
||||
->setDtStart(new \DateTime('2012-12-24'))
|
||||
->setDtEnd(new \DateTime('2012-12-24'))
|
||||
->setNoTime(true)
|
||||
->setSummary('Christmas')
|
||||
;
|
||||
```
|
||||
|
||||
#### 4. Add Event to Calendar
|
||||
|
||||
```PHP
|
||||
$vCalendar->addComponent($vEvent);
|
||||
```
|
||||
|
||||
#### 5. Set HTTP-headers
|
||||
|
||||
```PHP
|
||||
header('Content-Type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="cal.ics"');
|
||||
```
|
||||
|
||||
#### 6. Send output
|
||||
|
||||
```PHP
|
||||
echo $vCalendar->render();
|
||||
```
|
||||
|
||||
### Timezone support
|
||||
|
||||
This package supports three different types of handling timezones:
|
||||
|
||||
#### 1. UTC (default)
|
||||
|
||||
In the default setting, UTC/GMT will be used as Timezone. The time will be formated as following:
|
||||
|
||||
```
|
||||
DTSTART:20121224T180000Z
|
||||
```
|
||||
|
||||
#### 2. Use explicit timezone
|
||||
|
||||
You can use an explicit timezone by calling `$vEvent->setUseTimezone(true);`. The timezone of your
|
||||
`\DateTime` object will be used. In this case the non-standard field "X-WR-TIMEZONE" will be used.
|
||||
Be awre that this is a simple solution which is not supported by all calendar clients.
|
||||
The output will be as following:
|
||||
|
||||
```
|
||||
DTSTART;TZID=Europe/Berlin:20121224T180000
|
||||
```
|
||||
|
||||
#### 3. Use explicit timezone with definition
|
||||
|
||||
You can use an explicit timezone and define it using `Timezone()` and `TimezoneRule()` (see example5.php).
|
||||
The timezone of your `\DateTime` object will be used. The output will be as following:
|
||||
|
||||
```
|
||||
BEGIN:VTIMEZONE
|
||||
TZID:Europe/Berlin
|
||||
X-LIC-LOCATION:Europe/Berlin
|
||||
BEGIN:DAYLIGHT
|
||||
TZOFFSETFROM:+0100
|
||||
TZOFFSETTO:+0200
|
||||
DTSTART:19810329T030000
|
||||
RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=3;BYDAY=-1SU
|
||||
END:DAYLIGHT
|
||||
BEGIN:STANDARD
|
||||
TZOFFSETFROM:+0200
|
||||
TZOFFSETTO:+0100
|
||||
DTSTART:19961027T030000
|
||||
RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
|
||||
END:STANDARD
|
||||
END:VTIMEZONE
|
||||
...
|
||||
DTSTART;TZID=Europe/Berlin:20121224T180000
|
||||
```
|
||||
|
||||
#### 4. Use locale time
|
||||
|
||||
You can use local time by calling `$vEvent->setUseUtc(false);`. The output will be:
|
||||
|
||||
```
|
||||
DTSTART:20121224T180000
|
||||
```
|
||||
|
||||
## Running the tests
|
||||
|
||||
To setup and run tests:
|
||||
|
||||
- go to the root directory of this project
|
||||
- download composer: `wget https://getcomposer.org/composer.phar`
|
||||
- install dev dependencies: `php composer.phar install --dev`
|
||||
- run `./bin/phpunit`
|
||||
|
||||
## License
|
||||
|
||||
This package is released under the __MIT license__.
|
||||
|
||||
Copyright (c) 2012-2015 Markus Poerschke
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
9
vendor/eluceo/ical/UPGRADE.md
vendored
9
vendor/eluceo/ical/UPGRADE.md
vendored
@@ -1,9 +0,0 @@
|
||||
# v0.8.0 -> v0.9.0
|
||||
|
||||
- The signature of the ```Event::setOrganizer``` method was changed:
|
||||
Now there is is only one parameter that must be an instance of ```Property\Organizer```.
|
||||
|
||||
# v0.7.0 -> v0.8.0
|
||||
|
||||
- The signature of the ```Event::setOrganizer``` method was changed: Now there are
|
||||
two parameters name and email instead of an already formatted string.
|
||||
27
vendor/eluceo/ical/composer.json
vendored
27
vendor/eluceo/ical/composer.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eluceo/ical",
|
||||
"description": "The eluceo/iCal package offers a abstraction layer for creating iCalendars. You can easily create iCal files by using PHP object instead of typing your *.ics file by hand. The output will follow RFC 2445 as best as possible.",
|
||||
"description": "The eluceo/iCal package offers a abstraction layer for creating iCalendars. You can easily create iCal files by using PHP object instead of typing your *.ics file by hand. The output will follow RFC 5545 as best as possible.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/markuspoerschke/iCal",
|
||||
"authors": [
|
||||
@@ -8,11 +8,6 @@
|
||||
"name": "Markus Poerschke",
|
||||
"email": "markus@eluceo.de",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Maciej Łebkowski",
|
||||
"email": "m.lebkowski@gmail.com",
|
||||
"role": "Contributor"
|
||||
}
|
||||
],
|
||||
"keywords": [
|
||||
@@ -27,17 +22,25 @@
|
||||
"source": "https://github.com/markuspoerschke/iCal"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Eluceo\\iCal": "src/"
|
||||
"psr-4": {
|
||||
"Eluceo\\iCal\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Eluceo\\iCal\\": "tests/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring" : "Massive performance enhancement of line folding"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.3"
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
"scripts": {
|
||||
"test": "phpunit"
|
||||
}
|
||||
}
|
||||
|
||||
30
vendor/eluceo/ical/examples/example1.php
vendored
30
vendor/eluceo/ical/examples/example1.php
vendored
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
// use composer autoloader
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// set default timezone (PHP 5.4)
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
|
||||
// 1. Create new calendar
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
|
||||
// 2. Create an event
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2012-12-24'));
|
||||
$vEvent->setDtEnd(new \DateTime('2012-12-24'));
|
||||
$vEvent->setNoTime(true);
|
||||
$vEvent->setSummary('Christmas');
|
||||
|
||||
// Adding Timezone (optional)
|
||||
$vEvent->setUseTimezone(true);
|
||||
|
||||
// 3. Add event to calendar
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
// 4. Set headers
|
||||
header('Content-Type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="cal.ics"');
|
||||
|
||||
// 5. Output
|
||||
echo $vCalendar->render();
|
||||
31
vendor/eluceo/ical/examples/example2.php
vendored
31
vendor/eluceo/ical/examples/example2.php
vendored
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
// use composer autoloader
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// set default timezone (PHP 5.4)
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
|
||||
// 1. Create new calendar
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
|
||||
// 2. Create an event
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2012-12-24'));
|
||||
$vEvent->setDtEnd(new \DateTime('2012-12-24'));
|
||||
$vEvent->setNoTime(true);
|
||||
$vEvent->setSummary('Summary with some german "umlauten" and a backslash \\: Kinder mögen Äpfel pflücken.');
|
||||
$vEvent->setCategories(['holidays']);
|
||||
|
||||
// Adding Timezone (optional)
|
||||
$vEvent->setUseTimezone(true);
|
||||
|
||||
// 3. Add event to calendar
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
// 4. Set headers
|
||||
header('Content-Type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="cal.ics"');
|
||||
|
||||
// 5. Output
|
||||
echo $vCalendar->render();
|
||||
36
vendor/eluceo/ical/examples/example3.php
vendored
36
vendor/eluceo/ical/examples/example3.php
vendored
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
// use composer autoloader
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// set default timezone (PHP 5.4)
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
|
||||
// 1. Create new calendar
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
|
||||
// 2. Create an event
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2012-12-31'));
|
||||
$vEvent->setDtEnd(new \DateTime('2012-12-31'));
|
||||
$vEvent->setNoTime(true);
|
||||
$vEvent->setSummary('New Year’s Eve');
|
||||
|
||||
// Set recurrence rule
|
||||
$recurrenceRule = new \Eluceo\iCal\Property\Event\RecurrenceRule();
|
||||
$recurrenceRule->setFreq(\Eluceo\iCal\Property\Event\RecurrenceRule::FREQ_YEARLY);
|
||||
$recurrenceRule->setInterval(1);
|
||||
$vEvent->setRecurrenceRule($recurrenceRule);
|
||||
|
||||
// Adding Timezone (optional)
|
||||
$vEvent->setUseTimezone(true);
|
||||
|
||||
// 3. Add event to calendar
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
// 4. Set headers
|
||||
header('Content-Type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="cal.ics"');
|
||||
|
||||
// 5. Output
|
||||
echo $vCalendar->render();
|
||||
35
vendor/eluceo/ical/examples/example4.php
vendored
35
vendor/eluceo/ical/examples/example4.php
vendored
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
// use composer autoloader
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// set default timezone (PHP 5.4)
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
|
||||
// 1. Create new calendar
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
|
||||
// 2. Create an event
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2012-11-11 13:00:00'));
|
||||
$vEvent->setDtEnd(new \DateTime('2012-11-11 14:30:00'));
|
||||
$vEvent->setSummary('Weekly lunch with Markus');
|
||||
|
||||
// Set recurrence rule
|
||||
$recurrenceRule = new \Eluceo\iCal\Property\Event\RecurrenceRule();
|
||||
$recurrenceRule->setFreq(\Eluceo\iCal\Property\Event\RecurrenceRule::FREQ_WEEKLY);
|
||||
$recurrenceRule->setInterval(1);
|
||||
$vEvent->setRecurrenceRule($recurrenceRule);
|
||||
|
||||
// Adding Timezone (optional)
|
||||
$vEvent->setUseTimezone(true);
|
||||
|
||||
// 3. Add event to calendar
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
// 4. Set headers
|
||||
header('Content-Type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="cal.ics"');
|
||||
|
||||
// 5. Output
|
||||
echo $vCalendar->render();
|
||||
66
vendor/eluceo/ical/examples/example5.php
vendored
66
vendor/eluceo/ical/examples/example5.php
vendored
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* example to show how to create an ICal calendar which
|
||||
* provides a full timezone definition
|
||||
*/
|
||||
|
||||
// use composer autoloader
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// set default timezone (PHP 5.4)
|
||||
$tz = 'Europe/Berlin';
|
||||
$dtz = new \DateTimeZone($tz);
|
||||
date_default_timezone_set($tz);
|
||||
|
||||
// 1. Create new calendar
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
|
||||
// 2. Create timezone rule object for Daylight Saving Time
|
||||
$vTimezoneRuleDst = new \Eluceo\iCal\Component\TimezoneRule(\Eluceo\iCal\Component\TimezoneRule::TYPE_DAYLIGHT);
|
||||
$vTimezoneRuleDst->setTzName('CEST');
|
||||
$vTimezoneRuleDst->setDtStart(new \DateTime('1981-03-29 02:00:00', $dtz));
|
||||
$vTimezoneRuleDst->setTzOffsetFrom('+0100');
|
||||
$vTimezoneRuleDst->setTzOffsetTo('+0200');
|
||||
$dstRecurrenceRule = new \Eluceo\iCal\Property\Event\RecurrenceRule();
|
||||
$dstRecurrenceRule->setFreq(\Eluceo\iCal\Property\Event\RecurrenceRule::FREQ_YEARLY);
|
||||
$dstRecurrenceRule->setByMonth(3);
|
||||
$dstRecurrenceRule->setByDay('-1SU');
|
||||
$vTimezoneRuleDst->setRecurrenceRule($dstRecurrenceRule);
|
||||
|
||||
// 3. Create timezone rule object for Standard Time
|
||||
$vTimezoneRuleStd = new \Eluceo\iCal\Component\TimezoneRule(\Eluceo\iCal\Component\TimezoneRule::TYPE_STANDARD);
|
||||
$vTimezoneRuleStd->setTzName('CET');
|
||||
$vTimezoneRuleStd->setDtStart(new \DateTime('1996-10-27 03:00:00', $dtz));
|
||||
$vTimezoneRuleStd->setTzOffsetFrom('+0200');
|
||||
$vTimezoneRuleStd->setTzOffsetTo('+0100');
|
||||
$stdRecurrenceRule = new \Eluceo\iCal\Property\Event\RecurrenceRule();
|
||||
$stdRecurrenceRule->setFreq(\Eluceo\iCal\Property\Event\RecurrenceRule::FREQ_YEARLY);
|
||||
$stdRecurrenceRule->setByMonth(10);
|
||||
$stdRecurrenceRule->setByDay('-1SU');
|
||||
$vTimezoneRuleStd->setRecurrenceRule($stdRecurrenceRule);
|
||||
|
||||
// 4. Create timezone definition and add rules
|
||||
$vTimezone = new \Eluceo\iCal\Component\Timezone($tz);
|
||||
$vTimezone->addComponent($vTimezoneRuleDst);
|
||||
$vTimezone->addComponent($vTimezoneRuleStd);
|
||||
$vCalendar->setTimezone($vTimezone);
|
||||
|
||||
// 5. Create an event
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2012-12-24', $dtz));
|
||||
$vEvent->setDtEnd(new \DateTime('2012-12-24', $dtz));
|
||||
$vEvent->setSummary('Summary with some german "umlauten" and a backslash \\: Kinder mögen Äpfel pflücken.');
|
||||
|
||||
// 6. Adding Timezone
|
||||
$vEvent->setUseTimezone(true);
|
||||
|
||||
// 7. Add event to calendar
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
// 8. Set headers
|
||||
header('Content-Type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="cal.ics"');
|
||||
|
||||
// 9. Output
|
||||
echo $vCalendar->render();
|
||||
30
vendor/eluceo/ical/examples/example6.php
vendored
30
vendor/eluceo/ical/examples/example6.php
vendored
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
// use composer autoloader
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// set default timezone (PHP 5.4)
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
|
||||
// 1. Create new calendar
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
|
||||
// 2. Create an event
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2012-12-24'));
|
||||
$vEvent->setDtEnd(new \DateTime('2012-12-24'));
|
||||
$vEvent->setNoTime(true);
|
||||
$vEvent->setSummary('Christmas');
|
||||
|
||||
// add some location information for apple devices
|
||||
$vEvent->setLocation("Infinite Loop\nCupertino CA 95014", 'Infinite Loop', '37.332095,-122.030743');
|
||||
|
||||
// 3. Add event to calendar
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
// 4. Set headers
|
||||
header('Content-Type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="cal.ics"');
|
||||
|
||||
// 5. Output
|
||||
echo $vCalendar->render();
|
||||
33
vendor/eluceo/ical/examples/example7.php
vendored
33
vendor/eluceo/ical/examples/example7.php
vendored
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
// use composer autoloader
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// set default timezone (PHP 5.4)
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
|
||||
// 1. Create new calendar
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
|
||||
// 2. Create an event
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2012-12-24'));
|
||||
$vEvent->setDtEnd(new \DateTime('2012-12-24'));
|
||||
$vEvent->setNoTime(true);
|
||||
$vEvent->setSummary('Christmas');
|
||||
$vEvent->setDescription('Happy Christmas!');
|
||||
$vEvent->setDescriptionHTML('<b>Happy Christmas!</b>');
|
||||
|
||||
|
||||
// add some location information for apple devices
|
||||
$vEvent->setLocation("Infinite Loop\nCupertino CA 95014", 'Infinite Loop', '37.332095,-122.030743');
|
||||
|
||||
// 3. Add event to calendar
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
// 4. Set headers
|
||||
header('Content-Type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="cal.ics"');
|
||||
|
||||
// 5. Output
|
||||
echo $vCalendar->render();
|
||||
21
vendor/eluceo/ical/phpunit.xml.dist
vendored
21
vendor/eluceo/ical/phpunit.xml.dist
vendored
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="./vendor/autoload.php">
|
||||
<logging>
|
||||
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true" showOnlySummary="true"/>
|
||||
</logging>
|
||||
<testsuites>
|
||||
<testsuite name="eluceo iCal Test Suite">
|
||||
<directory suffix="Test.php">./tests/Eluceo/iCal/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
@@ -23,7 +23,7 @@ abstract class Component
|
||||
*
|
||||
* @var Component[]
|
||||
*/
|
||||
protected $components = array();
|
||||
protected $components = [];
|
||||
|
||||
/**
|
||||
* The order in which the components will be rendered during build.
|
||||
@@ -32,7 +32,7 @@ abstract class Component
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $componentsBuildOrder = array('VTIMEZONE', 'DAYLIGHT', 'STANDARD');
|
||||
private $componentsBuildOrder = ['VTIMEZONE', 'DAYLIGHT', 'STANDARD'];
|
||||
|
||||
/**
|
||||
* The type of the concrete Component.
|
||||
@@ -60,7 +60,7 @@ abstract class Component
|
||||
* @param Component $component The Component that will be added
|
||||
* @param null $key The key of the Component
|
||||
*/
|
||||
public function addComponent(Component $component, $key = null)
|
||||
public function addComponent(self $component, $key = null)
|
||||
{
|
||||
if (null == $key) {
|
||||
$this->components[] = $component;
|
||||
@@ -69,6 +69,19 @@ abstract class Component
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all Components.
|
||||
*
|
||||
* @param Component[] $components The array of Component that will be set
|
||||
* @param null $key The key of the Component
|
||||
*/
|
||||
public function setComponents(array $components)
|
||||
{
|
||||
$this->components = $components;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an array containing the lines of the iCal file.
|
||||
*
|
||||
@@ -76,7 +89,7 @@ abstract class Component
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
|
||||
$lines[] = sprintf('BEGIN:%s', $this->getType());
|
||||
|
||||
@@ -91,7 +104,7 @@ abstract class Component
|
||||
|
||||
$lines[] = sprintf('END:%s', $this->getType());
|
||||
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
foreach (ComponentUtil::fold($line) as $l) {
|
||||
@@ -129,13 +142,13 @@ abstract class Component
|
||||
*/
|
||||
private function buildComponents(array &$lines)
|
||||
{
|
||||
$componentsByType = array();
|
||||
$componentsByType = [];
|
||||
|
||||
/** @var $component Component */
|
||||
foreach ($this->components as $component) {
|
||||
$type = $component->getType();
|
||||
if (!isset($componentsByType[$type])) {
|
||||
$componentsByType[$type] = array();
|
||||
$componentsByType[$type] = [];
|
||||
}
|
||||
$componentsByType[$type][] = $component;
|
||||
}
|
||||
@@ -160,10 +173,9 @@ abstract class Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $lines
|
||||
* @param Component $component
|
||||
*/
|
||||
private function addComponentLines(array &$lines, Component $component)
|
||||
private function addComponentLines(array &$lines, self $component)
|
||||
{
|
||||
foreach ($component->build() as $l) {
|
||||
$lines[] = $l;
|
||||
@@ -13,7 +13,6 @@ namespace Eluceo\iCal\Component;
|
||||
|
||||
use Eluceo\iCal\Component;
|
||||
use Eluceo\iCal\PropertyBag;
|
||||
use Eluceo\iCal\Property;
|
||||
|
||||
/**
|
||||
* Implementation of the VALARM component.
|
||||
@@ -25,11 +24,11 @@ class Alarm extends Component
|
||||
*
|
||||
* According to RFC 5545: 3.8.6.1. Action
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc5545#section-3.8.6.1
|
||||
* @see http://tools.ietf.org/html/rfc5545#section-3.8.6.1
|
||||
*/
|
||||
const ACTION_AUDIO = 'AUDIO';
|
||||
const ACTION_AUDIO = 'AUDIO';
|
||||
const ACTION_DISPLAY = 'DISPLAY';
|
||||
const ACTION_EMAIL = 'EMAIL';
|
||||
const ACTION_EMAIL = 'EMAIL';
|
||||
|
||||
protected $action;
|
||||
protected $repeat;
|
||||
@@ -19,20 +19,20 @@ class Calendar extends Component
|
||||
/**
|
||||
* Methods for calendar components.
|
||||
*
|
||||
* According to RFP 5545: 3.7.2. Method
|
||||
* According to RFC 5545: 3.7.2. Method
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc5545#section-3.7.2
|
||||
* @see http://tools.ietf.org/html/rfc5545#section-3.7.2
|
||||
*
|
||||
* And then according to RFC 2446: 3 APPLICATION PROTOCOL ELEMENTS
|
||||
* @link https://www.ietf.org/rfc/rfc2446.txt
|
||||
* @see https://tools.ietf.org/html/rfc2446#section-3.2
|
||||
*/
|
||||
const METHOD_PUBLISH = 'PUBLISH';
|
||||
const METHOD_REQUEST = 'REQUEST';
|
||||
const METHOD_REPLY = 'REPLY';
|
||||
const METHOD_ADD = 'ADD';
|
||||
const METHOD_CANCEL = 'CANCEL';
|
||||
const METHOD_REFRESH = 'REFRESH';
|
||||
const METHOD_COUNTER = 'COUNTER';
|
||||
const METHOD_PUBLISH = 'PUBLISH';
|
||||
const METHOD_REQUEST = 'REQUEST';
|
||||
const METHOD_REPLY = 'REPLY';
|
||||
const METHOD_ADD = 'ADD';
|
||||
const METHOD_CANCEL = 'CANCEL';
|
||||
const METHOD_REFRESH = 'REFRESH';
|
||||
const METHOD_COUNTER = 'COUNTER';
|
||||
const METHOD_DECLINECOUNTER = 'DECLINECOUNTER';
|
||||
|
||||
/**
|
||||
@@ -40,26 +40,26 @@ class Calendar extends Component
|
||||
*
|
||||
* According to RFC 5545: 3.7.1. Calendar Scale
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc5545#section-3.7
|
||||
* @see http://tools.ietf.org/html/rfc5545#section-3.7
|
||||
*/
|
||||
const CALSCALE_GREGORIAN = 'GREGORIAN';
|
||||
|
||||
/**
|
||||
* The Product Identifier.
|
||||
*
|
||||
* According to RFC 2445: 4.7.3 Product Identifier
|
||||
* According to RFC 5545: 3.7.3 Product Identifier
|
||||
*
|
||||
* This property specifies the identifier for the product that created the Calendar object.
|
||||
*
|
||||
* @link http://www.ietf.org/rfc/rfc2445.txt
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.7.3
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prodId = null;
|
||||
protected $method = null;
|
||||
protected $name = null;
|
||||
protected $prodId = null;
|
||||
protected $method = null;
|
||||
protected $name = null;
|
||||
protected $description = null;
|
||||
protected $timezone = null;
|
||||
protected $timezone = null;
|
||||
|
||||
/**
|
||||
* This property defines the calendar scale used for the
|
||||
@@ -96,11 +96,14 @@ class Calendar extends Component
|
||||
* Specifies a suggested iCalendar file download frequency for clients and
|
||||
* servers with sync capabilities.
|
||||
*
|
||||
* For example you can set the value to 'P1W' if the calendar should be
|
||||
* synced once a week. Use 'P3H' to sync the file every 3 hours.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @see http://msdn.microsoft.com/en-us/library/ee178699(v=exchg.80).aspx
|
||||
*/
|
||||
protected $publishedTTL = 'P1W';
|
||||
protected $publishedTTL = null;
|
||||
|
||||
/**
|
||||
* Specifies a color for the calendar in calendar for Apple/Outlook.
|
||||
@@ -300,8 +303,6 @@ class Calendar extends Component
|
||||
*
|
||||
* @see Eluceo\iCal::addComponent
|
||||
* @deprecated Please, use public method addComponent() from abstract Component class
|
||||
*
|
||||
* @param Event $event
|
||||
*/
|
||||
public function addEvent(Event $event)
|
||||
{
|
||||
@@ -309,7 +310,7 @@ class Calendar extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getProdId()
|
||||
{
|
||||
@@ -14,26 +14,33 @@ namespace Eluceo\iCal\Component;
|
||||
use Eluceo\iCal\Component;
|
||||
use Eluceo\iCal\Property;
|
||||
use Eluceo\iCal\Property\DateTimeProperty;
|
||||
use Eluceo\iCal\Property\Event\Attendees;
|
||||
use Eluceo\iCal\Property\Event\Organizer;
|
||||
use Eluceo\iCal\Property\Event\RecurrenceRule;
|
||||
use Eluceo\iCal\Property\Event\Description;
|
||||
use Eluceo\iCal\PropertyBag;
|
||||
use Eluceo\iCal\Property\Event\RecurrenceId;
|
||||
use Eluceo\iCal\Property\DateTimesProperty;
|
||||
use Eluceo\iCal\Property\Event\Attachment;
|
||||
use Eluceo\iCal\Property\Event\Attendees;
|
||||
use Eluceo\iCal\Property\Event\Geo;
|
||||
use Eluceo\iCal\Property\Event\Organizer;
|
||||
use Eluceo\iCal\Property\Event\RecurrenceId;
|
||||
use Eluceo\iCal\Property\Event\RecurrenceRule;
|
||||
use Eluceo\iCal\Property\RawStringValue;
|
||||
use Eluceo\iCal\PropertyBag;
|
||||
|
||||
/**
|
||||
* Implementation of the EVENT component.
|
||||
*/
|
||||
class Event extends Component
|
||||
{
|
||||
const TIME_TRANSPARENCY_OPAQUE = 'OPAQUE';
|
||||
const TIME_TRANSPARENCY_OPAQUE = 'OPAQUE';
|
||||
const TIME_TRANSPARENCY_TRANSPARENT = 'TRANSPARENT';
|
||||
|
||||
const STATUS_TENTATIVE = 'TENTATIVE';
|
||||
const STATUS_CONFIRMED = 'CONFIRMED';
|
||||
const STATUS_CANCELLED = 'CANCELLED';
|
||||
|
||||
const MS_BUSYSTATUS_FREE = 'FREE';
|
||||
const MS_BUSYSTATUS_TENTATIVE = 'TENTATIVE';
|
||||
const MS_BUSYSTATUS_BUSY = 'BUSY';
|
||||
const MS_BUSYSTATUS_OOF = 'OOF';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -71,6 +78,11 @@ class Event extends Component
|
||||
*/
|
||||
protected $noTime = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $msBusyStatus = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -87,7 +99,7 @@ class Event extends Component
|
||||
protected $locationTitle;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @var Geo
|
||||
*/
|
||||
protected $locationGeo;
|
||||
|
||||
@@ -102,7 +114,7 @@ class Event extends Component
|
||||
protected $organizer;
|
||||
|
||||
/**
|
||||
* @see http://www.ietf.org/rfc/rfc2445.txt 4.8.2.7 Time Transparency
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.2.7
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
@@ -115,6 +127,13 @@ class Event extends Component
|
||||
*/
|
||||
protected $useTimezone = false;
|
||||
|
||||
/**
|
||||
* If set will be used as the timezone identifier.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $timezoneString = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
@@ -145,6 +164,11 @@ class Event extends Component
|
||||
*/
|
||||
protected $recurrenceRule;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $recurrenceRules = [];
|
||||
|
||||
/**
|
||||
* This property specifies the date and time that the calendar
|
||||
* information was created.
|
||||
@@ -198,22 +222,28 @@ class Event extends Component
|
||||
/**
|
||||
* Dates to be excluded from a series of events.
|
||||
*
|
||||
* @var \DateTime[]
|
||||
* @var \DateTimeInterface[]
|
||||
*/
|
||||
protected $exDates = array();
|
||||
protected $exDates = [];
|
||||
|
||||
/**
|
||||
* @var RecurrenceId
|
||||
*/
|
||||
protected $recurrenceId;
|
||||
|
||||
public function __construct($uniqueId = null)
|
||||
/**
|
||||
* @var Attachment[]
|
||||
*/
|
||||
protected $attachments = [];
|
||||
|
||||
public function __construct(string $uniqueId = null)
|
||||
{
|
||||
if (null == $uniqueId) {
|
||||
$uniqueId = uniqid();
|
||||
}
|
||||
|
||||
$this->uniqueId = $uniqueId;
|
||||
$this->attendees = new Attendees();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +264,7 @@ class Event extends Component
|
||||
// mandatory information
|
||||
$propertyBag->set('UID', $this->uniqueId);
|
||||
|
||||
$propertyBag->add(new DateTimeProperty('DTSTART', $this->dtStart, $this->noTime, $this->useTimezone, $this->useUtc));
|
||||
$propertyBag->add(new DateTimeProperty('DTSTART', $this->dtStart, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
|
||||
$propertyBag->set('SEQUENCE', $this->sequence);
|
||||
$propertyBag->set('TRANSP', $this->transparency);
|
||||
|
||||
@@ -243,9 +273,13 @@ class Event extends Component
|
||||
}
|
||||
|
||||
// An event can have a 'dtend' or 'duration', but not both.
|
||||
if (null != $this->dtEnd) {
|
||||
$propertyBag->add(new DateTimeProperty('DTEND', $this->dtEnd, $this->noTime, $this->useTimezone, $this->useUtc));
|
||||
} elseif (null != $this->duration) {
|
||||
if ($this->dtEnd !== null) {
|
||||
$dtEnd = clone $this->dtEnd;
|
||||
if ($this->noTime === true) {
|
||||
$dtEnd = $dtEnd->add(new \DateInterval('P1D'));
|
||||
}
|
||||
$propertyBag->add(new DateTimeProperty('DTEND', $dtEnd, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
|
||||
} elseif ($this->duration !== null) {
|
||||
$propertyBag->set('DURATION', $this->duration->format('P%dDT%hH%iM%sS'));
|
||||
}
|
||||
|
||||
@@ -261,19 +295,22 @@ class Event extends Component
|
||||
$propertyBag->add(
|
||||
new Property(
|
||||
'X-APPLE-STRUCTURED-LOCATION',
|
||||
'geo:' . $this->locationGeo,
|
||||
array(
|
||||
'VALUE' => 'URI',
|
||||
'X-ADDRESS' => $this->location,
|
||||
new RawStringValue('geo:' . $this->locationGeo->getGeoLocationAsString(',')),
|
||||
[
|
||||
'VALUE' => 'URI',
|
||||
'X-ADDRESS' => $this->location,
|
||||
'X-APPLE-RADIUS' => 49,
|
||||
'X-TITLE' => $this->locationTitle,
|
||||
)
|
||||
'X-TITLE' => $this->locationTitle,
|
||||
]
|
||||
)
|
||||
);
|
||||
$propertyBag->set('GEO', str_replace(',', ';', $this->locationGeo));
|
||||
}
|
||||
}
|
||||
|
||||
if (null != $this->locationGeo) {
|
||||
$propertyBag->add($this->locationGeo);
|
||||
}
|
||||
|
||||
if (null != $this->summary) {
|
||||
$propertyBag->set('SUMMARY', $this->summary);
|
||||
}
|
||||
@@ -285,7 +322,7 @@ class Event extends Component
|
||||
$propertyBag->set('CLASS', $this->isPrivate ? 'PRIVATE' : 'PUBLIC');
|
||||
|
||||
if (null != $this->description) {
|
||||
$propertyBag->set('DESCRIPTION', new Description($this->description));
|
||||
$propertyBag->set('DESCRIPTION', $this->description);
|
||||
}
|
||||
|
||||
if (null != $this->descriptionHTML) {
|
||||
@@ -293,9 +330,9 @@ class Event extends Component
|
||||
new Property(
|
||||
'X-ALT-DESC',
|
||||
$this->descriptionHTML,
|
||||
array(
|
||||
[
|
||||
'FMTTYPE' => 'text/html',
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -304,13 +341,17 @@ class Event extends Component
|
||||
$propertyBag->set('RRULE', $this->recurrenceRule);
|
||||
}
|
||||
|
||||
foreach ($this->recurrenceRules as $recurrenceRule) {
|
||||
$propertyBag->set('RRULE', $recurrenceRule);
|
||||
}
|
||||
|
||||
if (null != $this->recurrenceId) {
|
||||
$this->recurrenceId->applyTimeSettings($this->noTime, $this->useTimezone, $this->useUtc);
|
||||
$this->recurrenceId->applyTimeSettings($this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString);
|
||||
$propertyBag->add($this->recurrenceId);
|
||||
}
|
||||
|
||||
if (!empty($this->exDates)) {
|
||||
$propertyBag->add(new DateTimesProperty('EXDATE', $this->exDates, $this->noTime, $this->useTimezone, $this->useUtc));
|
||||
$propertyBag->add(new DateTimesProperty('EXDATE', $this->exDates, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
|
||||
}
|
||||
|
||||
if ($this->cancelled) {
|
||||
@@ -325,12 +366,17 @@ class Event extends Component
|
||||
$propertyBag->set('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE');
|
||||
}
|
||||
|
||||
if (null != $this->msBusyStatus) {
|
||||
$propertyBag->set('X-MICROSOFT-CDO-BUSYSTATUS', $this->msBusyStatus);
|
||||
$propertyBag->set('X-MICROSOFT-CDO-INTENDEDSTATUS', $this->msBusyStatus);
|
||||
}
|
||||
|
||||
if (null != $this->categories) {
|
||||
$propertyBag->set('CATEGORIES', $this->categories);
|
||||
}
|
||||
|
||||
$propertyBag->add(
|
||||
new DateTimeProperty('DTSTAMP', $this->dtStamp ?: new \DateTime(), false, false, true)
|
||||
new DateTimeProperty('DTSTAMP', $this->dtStamp ?: new \DateTimeImmutable(), false, false, true)
|
||||
);
|
||||
|
||||
if ($this->created) {
|
||||
@@ -341,6 +387,10 @@ class Event extends Component
|
||||
$propertyBag->add(new DateTimeProperty('LAST-MODIFIED', $this->modified, false, false, true));
|
||||
}
|
||||
|
||||
foreach ($this->attachments as $attachment) {
|
||||
$propertyBag->add($attachment);
|
||||
}
|
||||
|
||||
return $propertyBag;
|
||||
}
|
||||
|
||||
@@ -368,6 +418,11 @@ class Event extends Component
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDtStart()
|
||||
{
|
||||
return $this->dtStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dtStamp
|
||||
*
|
||||
@@ -393,17 +448,34 @@ class Event extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $location
|
||||
* @param string $title
|
||||
* @param null $geo
|
||||
* @param string $location
|
||||
* @param string $title
|
||||
* @param Geo|string $geo
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocation($location, $title = '', $geo = null)
|
||||
{
|
||||
$this->location = $location;
|
||||
if (is_scalar($geo)) {
|
||||
$geo = Geo::fromString($geo);
|
||||
} elseif (!is_null($geo) && !$geo instanceof Geo) {
|
||||
$className = get_class($geo);
|
||||
throw new \InvalidArgumentException("The parameter 'geo' must be a string or an instance of " . Geo::class . " but an instance of {$className} was given.");
|
||||
}
|
||||
|
||||
$this->location = $location;
|
||||
$this->locationTitle = $title;
|
||||
$this->locationGeo = $geo;
|
||||
$this->locationGeo = $geo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setGeoLocation(Geo $geoProperty)
|
||||
{
|
||||
$this->locationGeo = $geoProperty;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -420,6 +492,37 @@ class Event extends Component
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $msBusyStatus
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setMsBusyStatus($msBusyStatus)
|
||||
{
|
||||
$msBusyStatus = strtoupper($msBusyStatus);
|
||||
if ($msBusyStatus == self::MS_BUSYSTATUS_FREE
|
||||
|| $msBusyStatus == self::MS_BUSYSTATUS_TENTATIVE
|
||||
|| $msBusyStatus == self::MS_BUSYSTATUS_BUSY
|
||||
|| $msBusyStatus == self::MS_BUSYSTATUS_OOF
|
||||
) {
|
||||
$this->msBusyStatus = $msBusyStatus;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid value for status');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMsBusyStatus()
|
||||
{
|
||||
return $this->msBusyStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sequence
|
||||
*
|
||||
@@ -441,8 +544,6 @@ class Event extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Organizer $organizer
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setOrganizer(Organizer $organizer)
|
||||
@@ -517,10 +618,28 @@ class Event extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Attendees $attendees
|
||||
* @param $timezoneString
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimezoneString($timezoneString)
|
||||
{
|
||||
$this->timezoneString = $timezoneString;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getTimezoneString()
|
||||
{
|
||||
return $this->timezoneString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setAttendees(Attendees $attendees)
|
||||
{
|
||||
$this->attendees = $attendees;
|
||||
@@ -534,20 +653,14 @@ class Event extends Component
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttendee($attendee, $params = array())
|
||||
public function addAttendee($attendee, $params = [])
|
||||
{
|
||||
if (!isset($this->attendees)) {
|
||||
$this->attendees = new Attendees();
|
||||
}
|
||||
$this->attendees->add($attendee, $params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attendees
|
||||
*/
|
||||
public function getAttendees()
|
||||
public function getAttendees(): Attendees
|
||||
{
|
||||
return $this->attendees;
|
||||
}
|
||||
@@ -660,25 +773,49 @@ class Event extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RecurrenceRule $recurrenceRule
|
||||
* @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use addRecurrenceRule instead.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRecurrenceRule(RecurrenceRule $recurrenceRule)
|
||||
{
|
||||
@trigger_error('setRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use addRecurrenceRule instead.', E_USER_DEPRECATED);
|
||||
|
||||
$this->recurrenceRule = $recurrenceRule;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use getRecurrenceRules instead.
|
||||
*
|
||||
* @return RecurrenceRule
|
||||
*/
|
||||
public function getRecurrenceRule()
|
||||
{
|
||||
@trigger_error('getRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use getRecurrenceRules instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->recurrenceRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addRecurrenceRule(RecurrenceRule $recurrenceRule)
|
||||
{
|
||||
$this->recurrenceRules[] = $recurrenceRule;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRecurrenceRules()
|
||||
{
|
||||
return $this->recurrenceRules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dtStamp
|
||||
*
|
||||
@@ -730,11 +867,9 @@ class Event extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $dateTime
|
||||
*
|
||||
* @return \Eluceo\iCal\Component\Event
|
||||
*/
|
||||
public function addExDate(\DateTime $dateTime)
|
||||
public function addExDate(\DateTimeInterface $dateTime)
|
||||
{
|
||||
$this->exDates[] = $dateTime;
|
||||
|
||||
@@ -742,7 +877,7 @@ class Event extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime[]
|
||||
* @return \DateTimeInterface[]
|
||||
*/
|
||||
public function getExDates()
|
||||
{
|
||||
@@ -750,7 +885,7 @@ class Event extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime[]
|
||||
* @param \DateTimeInterface[]
|
||||
*
|
||||
* @return \Eluceo\iCal\Component\Event
|
||||
*/
|
||||
@@ -770,8 +905,6 @@ class Event extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RecurrenceId $recurrenceId
|
||||
*
|
||||
* @return \Eluceo\iCal\Component\Event
|
||||
*/
|
||||
public function setRecurrenceId(RecurrenceId $recurrenceId)
|
||||
@@ -780,4 +913,29 @@ class Event extends Component
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $attachment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttachment(Attachment $attachment)
|
||||
{
|
||||
$this->attachments[] = $attachment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAttachments()
|
||||
{
|
||||
return $this->attachments;
|
||||
}
|
||||
|
||||
public function addUrlAttachment(string $url)
|
||||
{
|
||||
$this->addAttachment(new Attachment($url));
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@
|
||||
namespace Eluceo\iCal\Component;
|
||||
|
||||
use Eluceo\iCal\Component;
|
||||
use Eluceo\iCal\PropertyBag;
|
||||
use Eluceo\iCal\Property\Event\RecurrenceRule;
|
||||
use Eluceo\iCal\PropertyBag;
|
||||
|
||||
/**
|
||||
* Implementation of Standard Time and Daylight Saving Time observances (or rules)
|
||||
@@ -45,7 +45,7 @@ class TimezoneRule extends Component
|
||||
protected $tzName;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @var \DateTimeInterface
|
||||
*/
|
||||
protected $dtStart;
|
||||
|
||||
@@ -138,11 +138,9 @@ class TimezoneRule extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $dtStart
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDtStart(\DateTime $dtStart)
|
||||
public function setDtStart(\DateTimeInterface $dtStart)
|
||||
{
|
||||
$this->dtStart = $dtStart;
|
||||
|
||||
@@ -150,8 +148,6 @@ class TimezoneRule extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RecurrenceRule $recurrenceRule
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRecurrenceRule(RecurrenceRule $recurrenceRule)
|
||||
@@ -1,66 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?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\Util;
|
||||
|
||||
class ComponentUtil
|
||||
{
|
||||
/**
|
||||
* Folds a single line.
|
||||
*
|
||||
* According to RFC 2445, all lines longer than 75 characters will be folded
|
||||
*
|
||||
* @link http://www.ietf.org/rfc/rfc2445.txt
|
||||
*
|
||||
* @param $string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function fold($string)
|
||||
{
|
||||
$lines = array();
|
||||
$array = preg_split('/(?<!^)(?!$)/u', $string);
|
||||
|
||||
$line = '';
|
||||
$lineNo = 0;
|
||||
foreach ($array as $char) {
|
||||
$charLen = strlen($char);
|
||||
$lineLen = strlen($line);
|
||||
if ($lineLen + $charLen > 75) {
|
||||
$line = ' ' . $char;
|
||||
++$lineNo;
|
||||
} else {
|
||||
$line .= $char;
|
||||
}
|
||||
$lines[$lineNo] = $line;
|
||||
}
|
||||
|
||||
return $lines;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class ParameterBag
|
||||
*/
|
||||
protected $params;
|
||||
|
||||
public function __construct($params = array())
|
||||
public function __construct($params = [])
|
||||
{
|
||||
$this->params = $params;
|
||||
}
|
||||
@@ -36,33 +36,32 @@ class ParameterBag
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getParam($name)
|
||||
{
|
||||
if (array_key_exists($name, $this->params)) {
|
||||
if (isset($this->params[$name])) {
|
||||
return $this->params[$name];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are any params.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasParams()
|
||||
public function hasParams(): bool
|
||||
{
|
||||
return count($this->params) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
public function toString(): string
|
||||
{
|
||||
$line = '';
|
||||
foreach ($this->params as $param => $paramValues) {
|
||||
if (!is_array($paramValues)) {
|
||||
$paramValues = array($paramValues);
|
||||
$paramValues = [$paramValues];
|
||||
}
|
||||
foreach ($paramValues as $k => $v) {
|
||||
$paramValues[$k] = $this->escapeParamValue($v);
|
||||
@@ -85,7 +84,7 @@ class ParameterBag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeParamValue($value)
|
||||
private function escapeParamValue($value)
|
||||
{
|
||||
$count = 0;
|
||||
$value = str_replace('\\', '\\\\', $value);
|
||||
@@ -16,9 +16,11 @@ use Eluceo\iCal\Property\StringValue;
|
||||
use Eluceo\iCal\Property\ValueInterface;
|
||||
|
||||
/**
|
||||
* The Property Class represents a property as defined in RFC 2445.
|
||||
* The Property Class represents a property as defined in RFC 5545.
|
||||
*
|
||||
* The content of a line (unfolded) will be rendered in this class
|
||||
* The content of a line (unfolded) will be rendered in this class.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.5
|
||||
*/
|
||||
class Property
|
||||
{
|
||||
@@ -46,7 +48,7 @@ class Property
|
||||
* @param $value
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct($name, $value, $params = array())
|
||||
public function __construct($name, $value, $params = [])
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->setValue($value);
|
||||
@@ -82,7 +84,7 @@ class Property
|
||||
*/
|
||||
public function toLines()
|
||||
{
|
||||
return array($this->toLine());
|
||||
return [$this->toLine()];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,10 +140,7 @@ class Property
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
@@ -11,8 +11,6 @@
|
||||
|
||||
namespace Eluceo\iCal\Property;
|
||||
|
||||
use Eluceo\iCal\Util\PropertyValueUtil;
|
||||
|
||||
class ArrayValue implements ValueInterface
|
||||
{
|
||||
/**
|
||||
@@ -34,10 +32,10 @@ class ArrayValue implements ValueInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEscapedValue()
|
||||
public function getEscapedValue(): string
|
||||
{
|
||||
return implode(',', array_map(function ($value) {
|
||||
return PropertyValueUtil::escapeValue((string) $value);
|
||||
return implode(',', array_map(function (string $value): string {
|
||||
return (new StringValue($value))->getEscapedValue();
|
||||
}, $this->values));
|
||||
}
|
||||
}
|
||||
@@ -17,21 +17,23 @@ use Eluceo\iCal\Util\DateUtil;
|
||||
class DateTimeProperty extends Property
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
* @param \DateTime $dateTime
|
||||
* @param bool $noTime
|
||||
* @param bool $useTimezone
|
||||
* @param bool $useUtc
|
||||
* @param string $name
|
||||
* @param \DateTimeInterface $dateTime
|
||||
* @param bool $noTime
|
||||
* @param bool $useTimezone
|
||||
* @param bool $useUtc
|
||||
* @param string $timezoneString
|
||||
*/
|
||||
public function __construct(
|
||||
$name,
|
||||
\DateTime $dateTime = null,
|
||||
\DateTimeInterface $dateTime = null,
|
||||
$noTime = false,
|
||||
$useTimezone = false,
|
||||
$useUtc = false
|
||||
$useUtc = false,
|
||||
$timezoneString = ''
|
||||
) {
|
||||
$dateString = DateUtil::getDateString($dateTime, $noTime, $useTimezone, $useUtc);
|
||||
$params = DateUtil::getDefaultParams($dateTime, $noTime, $useTimezone);
|
||||
$params = DateUtil::getDefaultParams($dateTime, $noTime, $useTimezone, $timezoneString);
|
||||
|
||||
parent::__construct($name, $dateString, $params);
|
||||
}
|
||||
@@ -17,24 +17,29 @@ use Eluceo\iCal\Util\DateUtil;
|
||||
class DateTimesProperty extends Property
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
* @param \DateTime[] $dateTimes
|
||||
* @param bool $noTime
|
||||
* @param bool $useTimezone
|
||||
* @param bool $useUtc
|
||||
* @param string $name
|
||||
* @param \DateTimeInterface[] $dateTimes
|
||||
* @param bool $noTime
|
||||
* @param bool $useTimezone
|
||||
* @param bool $useUtc
|
||||
* @param string $timezoneString
|
||||
*/
|
||||
public function __construct(
|
||||
$name,
|
||||
$dateTimes = array(),
|
||||
$dateTimes = [],
|
||||
$noTime = false,
|
||||
$useTimezone = false,
|
||||
$useUtc = false
|
||||
$useUtc = false,
|
||||
$timezoneString = ''
|
||||
) {
|
||||
$dates = array();
|
||||
$dates = [];
|
||||
$dateTime = new \DateTimeImmutable();
|
||||
foreach ($dateTimes as $dateTime) {
|
||||
$dates[] = DateUtil::getDateString($dateTime, $noTime, $useTimezone, $useUtc);
|
||||
}
|
||||
$params = DateUtil::getDefaultParams($dateTime, $noTime, $useTimezone);
|
||||
|
||||
//@todo stop this triggering an E_NOTICE when $dateTimes is empty
|
||||
$params = DateUtil::getDefaultParams($dateTime, $noTime, $useTimezone, $timezoneString);
|
||||
|
||||
parent::__construct($name, $dates, $params);
|
||||
}
|
||||
39
vendor/eluceo/ical/src/Property/Event/Attachment.php
vendored
Normal file
39
vendor/eluceo/ical/src/Property/Event/Attachment.php
vendored
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);
|
||||
}
|
||||
}
|
||||
@@ -15,14 +15,15 @@ use Eluceo\iCal\Property;
|
||||
|
||||
class Attendees extends Property
|
||||
{
|
||||
/** @var Property[] */
|
||||
protected $attendees = array();
|
||||
|
||||
const PROPERTY_NAME = 'ATTENDEES';
|
||||
/**
|
||||
* @var Property[]
|
||||
*/
|
||||
protected $attendees = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Overwrites constructor functionality of Property
|
||||
$this->name = 'ATTENDEES';
|
||||
// prevent super constructor to be called
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +32,7 @@ class Attendees extends Property
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function add($value, $params = array())
|
||||
public function add($value, $params = [])
|
||||
{
|
||||
$this->attendees[] = new Property('ATTENDEE', $value, $params);
|
||||
|
||||
@@ -63,7 +64,7 @@ class Attendees extends Property
|
||||
*/
|
||||
public function toLines()
|
||||
{
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
foreach ($this->attendees as $attendee) {
|
||||
$lines[] = $attendee->toLine();
|
||||
}
|
||||
@@ -91,12 +92,4 @@ class Attendees extends Property
|
||||
{
|
||||
throw new \BadMethodCallException('Cannot call getParam on Attendees Property');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return self::PROPERTY_NAME;
|
||||
}
|
||||
}
|
||||
82
vendor/eluceo/ical/src/Property/Event/Geo.php
vendored
Normal file
82
vendor/eluceo/ical/src/Property/Event/Geo.php
vendored
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;
|
||||
}
|
||||
}
|
||||
@@ -18,22 +18,12 @@ use Eluceo\iCal\Property;
|
||||
*/
|
||||
class Organizer extends Property
|
||||
{
|
||||
const PROPERTY_NAME = 'ORGANIZER';
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct($value, $params = array())
|
||||
public function __construct($value, $params = [])
|
||||
{
|
||||
parent::__construct(self::PROPERTY_NAME, $value, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return self::PROPERTY_NAME;
|
||||
parent::__construct('ORGANIZER', $value, $params);
|
||||
}
|
||||
}
|
||||
@@ -13,29 +13,27 @@ namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
use Eluceo\iCal\ParameterBag;
|
||||
use Eluceo\iCal\Property;
|
||||
use Eluceo\iCal\Util\DateUtil;
|
||||
use Eluceo\iCal\Property\ValueInterface;
|
||||
use Eluceo\iCal\Util\DateUtil;
|
||||
|
||||
/**
|
||||
* Implementation of Recurrence Id.
|
||||
*
|
||||
* @see http://www.ietf.org/rfc/rfc2445.txt 4.8.4.4 Recurrence ID
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.4.4
|
||||
*/
|
||||
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_THISANDPRIOR = 'THISANDPRIOR';
|
||||
const RANGE_THISANDFUTURE = 'THISANDFUTURE';
|
||||
|
||||
/**
|
||||
* The dateTime to identify a particular instance of a recurring event which is getting modified.
|
||||
*
|
||||
* @var \DateTime
|
||||
* @var \DateTimeInterface
|
||||
*/
|
||||
protected $dateTime;
|
||||
|
||||
@@ -46,17 +44,18 @@ class RecurrenceId extends Property
|
||||
*/
|
||||
protected $range;
|
||||
|
||||
public function __construct(\DateTime $dateTime = null)
|
||||
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)
|
||||
public function applyTimeSettings($noTime = false, $useTimezone = false, $useUtc = false, $timezoneString = '')
|
||||
{
|
||||
$params = DateUtil::getDefaultParams($this->dateTime, $noTime, $useTimezone, $useUtc);
|
||||
$params = DateUtil::getDefaultParams($this->dateTime, $noTime, $useTimezone, $timezoneString);
|
||||
foreach ($params as $name => $value) {
|
||||
$this->parameterBag->setParam($name, $value);
|
||||
}
|
||||
@@ -69,7 +68,7 @@ class RecurrenceId extends Property
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
* @return \DateTimeInterface
|
||||
*/
|
||||
public function getDatetime()
|
||||
{
|
||||
@@ -77,11 +76,9 @@ class RecurrenceId extends Property
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $dateTime
|
||||
*
|
||||
* @return \Eluceo\iCal\Property\Event\RecurrenceId
|
||||
*/
|
||||
public function setDatetime(\DateTime $dateTime)
|
||||
public function setDatetime(\DateTimeInterface $dateTime)
|
||||
{
|
||||
$this->dateTime = $dateTime;
|
||||
|
||||
@@ -104,6 +101,8 @@ class RecurrenceId extends Property
|
||||
public function setRange($range)
|
||||
{
|
||||
$this->range = $range;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,12 +118,4 @@ class RecurrenceId extends Property
|
||||
return parent::toLines();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return self::PROPERTY_NAME;
|
||||
}
|
||||
}
|
||||
@@ -11,29 +11,32 @@
|
||||
|
||||
namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
use Eluceo\iCal\Property\ValueInterface;
|
||||
use Eluceo\iCal\ParameterBag;
|
||||
use Eluceo\iCal\Property\ValueInterface;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Implementation of Recurrence Rule.
|
||||
*
|
||||
* @see http://www.ietf.org/rfc/rfc2445.txt 3.3.10. Recurrence Rule
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.5.3
|
||||
*/
|
||||
class RecurrenceRule implements ValueInterface
|
||||
{
|
||||
const FREQ_YEARLY = 'YEARLY';
|
||||
const FREQ_YEARLY = 'YEARLY';
|
||||
const FREQ_MONTHLY = 'MONTHLY';
|
||||
const FREQ_WEEKLY = 'WEEKLY';
|
||||
const FREQ_DAILY = 'DAILY';
|
||||
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_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';
|
||||
const WEEKDAY_THURSDAY = 'TH';
|
||||
const WEEKDAY_FRIDAY = 'FR';
|
||||
const WEEKDAY_SATURDAY = 'SA';
|
||||
|
||||
/**
|
||||
* The frequency of an Event.
|
||||
@@ -43,73 +46,78 @@ class RecurrenceRule implements ValueInterface
|
||||
protected $freq = self::FREQ_YEARLY;
|
||||
|
||||
/**
|
||||
* @var null|int
|
||||
* BYSETPOS must require use of other BY*.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $canUseBySetPos = false;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
protected $interval = 1;
|
||||
|
||||
/**
|
||||
* @var null|int
|
||||
* @var int|null
|
||||
*/
|
||||
protected $count = null;
|
||||
|
||||
/**
|
||||
* @var null|\DateTime
|
||||
* @var \DateTimeInterface|null
|
||||
*/
|
||||
protected $until = null;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $wkst;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
* @var array|null
|
||||
*/
|
||||
protected $bySetPos = null;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byMonth;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byWeekNo;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byYearDay;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byMonthDay;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byDay;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byHour;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byMinute;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
* @var string|null
|
||||
*/
|
||||
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()
|
||||
public function getEscapedValue(): string
|
||||
{
|
||||
return $this->buildParameterBag()->toString();
|
||||
}
|
||||
@@ -139,36 +147,40 @@ class RecurrenceRule implements ValueInterface
|
||||
$parameterBag->setParam('WKST', $this->wkst);
|
||||
}
|
||||
|
||||
if (null !== $this->bySetPos && $this->canUseBySetPos) {
|
||||
$parameterBag->setParam('BYSETPOS', $this->bySetPos);
|
||||
}
|
||||
|
||||
if (null !== $this->byMonth) {
|
||||
$parameterBag->setParam('BYMONTH', $this->byMonth);
|
||||
$parameterBag->setParam('BYMONTH', explode(',', $this->byMonth));
|
||||
}
|
||||
|
||||
if (null !== $this->byWeekNo) {
|
||||
$parameterBag->setParam('BYWEEKNO', $this->byWeekNo);
|
||||
$parameterBag->setParam('BYWEEKNO', explode(',', $this->byWeekNo));
|
||||
}
|
||||
|
||||
if (null !== $this->byYearDay) {
|
||||
$parameterBag->setParam('BYYEARDAY', $this->byYearDay);
|
||||
$parameterBag->setParam('BYYEARDAY', explode(',', $this->byYearDay));
|
||||
}
|
||||
|
||||
if (null !== $this->byMonthDay) {
|
||||
$parameterBag->setParam('BYMONTHDAY', $this->byMonthDay);
|
||||
$parameterBag->setParam('BYMONTHDAY', explode(',', $this->byMonthDay));
|
||||
}
|
||||
|
||||
if (null !== $this->byDay) {
|
||||
$parameterBag->setParam('BYDAY', $this->byDay);
|
||||
$parameterBag->setParam('BYDAY', explode(',', $this->byDay));
|
||||
}
|
||||
|
||||
if (null !== $this->byHour) {
|
||||
$parameterBag->setParam('BYHOUR', $this->byHour);
|
||||
$parameterBag->setParam('BYHOUR', explode(',', $this->byHour));
|
||||
}
|
||||
|
||||
if (null !== $this->byMinute) {
|
||||
$parameterBag->setParam('BYMINUTE', $this->byMinute);
|
||||
$parameterBag->setParam('BYMINUTE', explode(',', $this->byMinute));
|
||||
}
|
||||
|
||||
if (null !== $this->bySecond) {
|
||||
$parameterBag->setParam('BYSECOND', $this->bySecond);
|
||||
$parameterBag->setParam('BYSECOND', explode(',', $this->bySecond));
|
||||
}
|
||||
|
||||
return $parameterBag;
|
||||
@@ -195,11 +207,9 @@ class RecurrenceRule implements ValueInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime|null $until
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUntil(\DateTime $until = null)
|
||||
public function setUntil(\DateTimeInterface $until = null)
|
||||
{
|
||||
$this->until = $until;
|
||||
|
||||
@@ -207,7 +217,7 @@ class RecurrenceRule implements ValueInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
* @return \DateTimeInterface|null
|
||||
*/
|
||||
public function getUntil()
|
||||
{
|
||||
@@ -235,10 +245,7 @@ class RecurrenceRule implements ValueInterface
|
||||
*/
|
||||
public function setFreq($freq)
|
||||
{
|
||||
if (self::FREQ_YEARLY === $freq || self::FREQ_MONTHLY === $freq
|
||||
|| self::FREQ_WEEKLY === $freq
|
||||
|| self::FREQ_DAILY === $freq
|
||||
) {
|
||||
if (@constant('static::FREQ_' . $freq) !== null) {
|
||||
$this->freq = $freq;
|
||||
} else {
|
||||
throw new \InvalidArgumentException("The Frequency {$freq} is not supported.");
|
||||
@@ -294,23 +301,88 @@ class RecurrenceRule implements ValueInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The BYMONTH rule part specifies a COMMA-separated list of months of the year.
|
||||
* Valid values are 1 to 12.
|
||||
* 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.
|
||||
*
|
||||
* @param int $month
|
||||
* 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) {
|
||||
if (!is_integer($month) || $month <= 0 || $month > 12) {
|
||||
throw new InvalidArgumentException('Invalid value for BYMONTH');
|
||||
}
|
||||
|
||||
$this->byMonth = $month;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -320,12 +392,20 @@ class RecurrenceRule implements ValueInterface
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
@@ -335,12 +415,20 @@ class RecurrenceRule implements ValueInterface
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
@@ -351,11 +439,19 @@ class RecurrenceRule implements ValueInterface
|
||||
* @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;
|
||||
}
|
||||
|
||||
@@ -368,14 +464,14 @@ class RecurrenceRule implements ValueInterface
|
||||
* 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)
|
||||
public function setByDay(string $day)
|
||||
{
|
||||
$this->byDay = $day;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -397,6 +493,8 @@ class RecurrenceRule implements ValueInterface
|
||||
|
||||
$this->byHour = $value;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -418,6 +516,8 @@ class RecurrenceRule implements ValueInterface
|
||||
|
||||
$this->byMinute = $value;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -439,6 +539,8 @@ class RecurrenceRule implements ValueInterface
|
||||
|
||||
$this->bySecond = $value;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
20
vendor/eluceo/ical/src/Property/RawStringValue.php
vendored
Normal file
20
vendor/eluceo/ical/src/Property/RawStringValue.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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;
|
||||
|
||||
class RawStringValue extends StringValue
|
||||
{
|
||||
public function getEscapedValue(): string
|
||||
{
|
||||
return $this->getValue();
|
||||
}
|
||||
}
|
||||
@@ -9,32 +9,59 @@
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Util;
|
||||
namespace Eluceo\iCal\Property;
|
||||
|
||||
class PropertyValueUtil
|
||||
class StringValue implements ValueInterface
|
||||
{
|
||||
public static function escapeValue($value)
|
||||
{
|
||||
$value = self::escapeValueAllowNewLine($value);
|
||||
$value = str_replace("\n", '\\n', $value);
|
||||
/**
|
||||
* The value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
return $value;
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public static function escapeValueAllowNewLine($value)
|
||||
public function getEscapedValue(): string
|
||||
{
|
||||
$value = $this->value;
|
||||
|
||||
$value = str_replace('\\', '\\\\', $value);
|
||||
$value = str_replace('"', '\\"', $value);
|
||||
$value = str_replace(',', '\\,', $value);
|
||||
$value = str_replace(';', '\\;', $value);
|
||||
$value = str_replace(array(
|
||||
$value = str_replace("\n", '\\n', $value);
|
||||
$value = str_replace([
|
||||
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
|
||||
"\x08", "\x09", /* \n*/ "\x0B", "\x0C", "\x0D", "\x0E", "\x0F",
|
||||
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
|
||||
"\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", "\x1E", "\x1F",
|
||||
"\x7F",
|
||||
), '', $value);
|
||||
], '', $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,9 @@ 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
|
||||
* Escape values as per RFC 5545.
|
||||
*
|
||||
* @return string
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.3.11
|
||||
*/
|
||||
public function getEscapedValue();
|
||||
public function getEscapedValue(): string;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class PropertyBag implements \IteratorAggregate
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $elements = array();
|
||||
protected $elements = [];
|
||||
|
||||
/**
|
||||
* Creates a new Property with $name, $value and $params.
|
||||
@@ -27,47 +27,41 @@ class PropertyBag implements \IteratorAggregate
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function set($name, $value, $params = array())
|
||||
public function set($name, $value, $params = [])
|
||||
{
|
||||
$property = new Property($name, $value, $params);
|
||||
$this->elements[] = $property;
|
||||
$this->add(new Property($name, $value, $params));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return null|Property
|
||||
* @return Property|null
|
||||
*/
|
||||
public function get($name)
|
||||
public function get(string $name)
|
||||
{
|
||||
// Searching Property in elements-array
|
||||
/** @var $property Property */
|
||||
foreach ($this->elements as $property) {
|
||||
if ($property->getName() == $name) {
|
||||
return $property;
|
||||
}
|
||||
if (isset($this->elements[$name])) {
|
||||
return $this->elements[$name];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Property. If Property already exists an Exception will be thrown.
|
||||
*
|
||||
* @param Property $property
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function add(Property $property)
|
||||
{
|
||||
// Property already exists?
|
||||
if (null !== $this->get($property->getName())) {
|
||||
throw new \Exception("Property with name '{$property->getName()}' already exists");
|
||||
$name = $property->getName();
|
||||
|
||||
if (isset($this->elements[$name])) {
|
||||
throw new \Exception("Property with name '{$name}' already exists");
|
||||
}
|
||||
|
||||
$this->elements[] = $property;
|
||||
$this->elements[$name] = $property;
|
||||
|
||||
return $this;
|
||||
}
|
||||
62
vendor/eluceo/ical/src/Util/ComponentUtil.php
vendored
Normal file
62
vendor/eluceo/ical/src/Util/ComponentUtil.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Util;
|
||||
|
||||
class ComponentUtil
|
||||
{
|
||||
/**
|
||||
* Folds a single line.
|
||||
*
|
||||
* According to RFC 5545, all lines longer than 75 characters should be folded
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-5
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.1
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function fold($string)
|
||||
{
|
||||
$lines = [];
|
||||
|
||||
if (function_exists('mb_strcut')) {
|
||||
while (strlen($string) > 0) {
|
||||
if (strlen($string) > 75) {
|
||||
$lines[] = mb_strcut($string, 0, 75, 'utf-8');
|
||||
$string = ' ' . mb_strcut($string, 75, strlen($string), 'utf-8');
|
||||
} else {
|
||||
$lines[] = $string;
|
||||
$string = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$array = preg_split('/(?<!^)(?!$)/u', $string);
|
||||
$line = '';
|
||||
$lineNo = 0;
|
||||
foreach ($array as $char) {
|
||||
$charLen = strlen($char);
|
||||
$lineLen = strlen($line);
|
||||
if ($lineLen + $charLen > 75) {
|
||||
$line = ' ' . $char;
|
||||
++$lineNo;
|
||||
} else {
|
||||
$line .= $char;
|
||||
}
|
||||
$lines[$lineNo] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
return $lines;
|
||||
}
|
||||
}
|
||||
@@ -13,12 +13,12 @@ namespace Eluceo\iCal\Util;
|
||||
|
||||
class DateUtil
|
||||
{
|
||||
public static function getDefaultParams(\DateTime $dateTime = null, $noTime = false, $useTimezone = false)
|
||||
public static function getDefaultParams(\DateTimeInterface $dateTime = null, $noTime = false, $useTimezone = false, $timezoneString = '')
|
||||
{
|
||||
$params = array();
|
||||
$params = [];
|
||||
|
||||
if ($useTimezone) {
|
||||
$timeZone = $dateTime->getTimezone()->getName();
|
||||
if ($useTimezone && $noTime === false) {
|
||||
$timeZone = $timezoneString === '' ? $dateTime->getTimezone()->getName() : $timezoneString;
|
||||
$params['TZID'] = $timeZone;
|
||||
}
|
||||
|
||||
@@ -32,17 +32,25 @@ class DateUtil
|
||||
/**
|
||||
* Returns a formatted date string.
|
||||
*
|
||||
* @param \DateTime|null $dateTime The DateTime object
|
||||
* @param bool $noTime Indicates if the time will be added
|
||||
* @param bool $useTimezone
|
||||
* @param bool $useUtc
|
||||
* @param \DateTimeInterface|null $dateTime The DateTime object
|
||||
* @param bool $noTime Indicates if the time will be added
|
||||
* @param bool $useTimezone
|
||||
* @param bool $useUtc
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getDateString(\DateTime $dateTime = null, $noTime = false, $useTimezone = false, $useUtc = false)
|
||||
public static function getDateString(\DateTimeInterface $dateTime = null, $noTime = false, $useTimezone = false, $useUtc = false)
|
||||
{
|
||||
if (empty($dateTime)) {
|
||||
$dateTime = new \DateTime();
|
||||
$dateTime = new \DateTimeImmutable();
|
||||
}
|
||||
|
||||
// Only convert the DateTime to UTC if there is a time present. For date-only the
|
||||
// timezone is meaningless and converting it might shift it to the wrong date.
|
||||
// Do not convert DateTime to UTC if a timezone it specified, as it should be local time.
|
||||
if (!$noTime && $useUtc && !$useTimezone) {
|
||||
$dateTime = clone $dateTime;
|
||||
$dateTime = $dateTime->setTimezone(new \DateTimeZone('UTC'));
|
||||
}
|
||||
|
||||
return $dateTime->format(self::getDateFormat($noTime, $useTimezone, $useUtc));
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal\Component;
|
||||
|
||||
class CalendarIntegrationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testExample3()
|
||||
{
|
||||
$timeZone = new \DateTimeZone('Europe/Berlin');
|
||||
|
||||
// 1. Create new calendar
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
|
||||
// 2. Create an event
|
||||
$vEvent = new \Eluceo\iCal\Component\Event('123456');
|
||||
$vEvent->setDtStart(new \DateTime('2012-12-31', $timeZone));
|
||||
$vEvent->setDtEnd(new \DateTime('2012-12-31', $timeZone));
|
||||
$vEvent->setNoTime(true);
|
||||
$vEvent->setIsPrivate(true);
|
||||
$vEvent->setSummary('New Year’s Eve');
|
||||
|
||||
// Set recurrence rule
|
||||
$recurrenceRule = new \Eluceo\iCal\Property\Event\RecurrenceRule();
|
||||
$recurrenceRule->setFreq(\Eluceo\iCal\Property\Event\RecurrenceRule::FREQ_YEARLY);
|
||||
$recurrenceRule->setInterval(1);
|
||||
$vEvent->setRecurrenceRule($recurrenceRule);
|
||||
|
||||
// Adding Timezone (optional)
|
||||
$vEvent->setUseTimezone(true);
|
||||
|
||||
// 3. Add event to calendar
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
$lines = array(
|
||||
'/BEGIN:VCALENDAR/',
|
||||
'/VERSION:2\.0/',
|
||||
'/PRODID:www\.example\.com/',
|
||||
'/X-PUBLISHED-TTL:P1W/',
|
||||
'/BEGIN:VEVENT/',
|
||||
'/UID:123456/',
|
||||
'/DTSTART;TZID=Europe\/Berlin;VALUE=DATE:20121231/',
|
||||
'/SEQUENCE:0/',
|
||||
'/TRANSP:OPAQUE/',
|
||||
'/DTEND;TZID=Europe\/Berlin;VALUE=DATE:20121231/',
|
||||
'/SUMMARY:New Year’s Eve/',
|
||||
'/CLASS:PRIVATE/',
|
||||
'/RRULE:FREQ=YEARLY;INTERVAL=1/',
|
||||
'/X-MICROSOFT-CDO-ALLDAYEVENT:TRUE/',
|
||||
'/DTSTAMP:20\d{6}T\d{6}Z/',
|
||||
'/END:VEVENT/',
|
||||
'/END:VCALENDAR/',
|
||||
);
|
||||
|
||||
foreach (explode("\n", $vCalendar->render()) as $key => $line)
|
||||
{
|
||||
$this->assertTrue(isset($lines[$key]), 'Too many lines... ' . $line);
|
||||
|
||||
$this->assertRegExp($lines[$key], $line);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
class ComponentTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFoldWithMultibyte()
|
||||
{
|
||||
$input = "x" . str_repeat("あいうえお", 5);
|
||||
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2014-12-24'));
|
||||
$vEvent->setDtEnd(new \DateTime('2014-12-24'));
|
||||
$vEvent->setDescription($input);
|
||||
|
||||
$vAlarm = new \Eluceo\iCal\Component\Alarm;
|
||||
$vAlarm->setAction(\Eluceo\iCal\Component\Alarm::ACTION_DISPLAY);
|
||||
$vAlarm->setDescription($input);
|
||||
$vAlarm->setTrigger('PT0S', true);
|
||||
$vEvent->addComponent($vAlarm);
|
||||
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
$output = $vCalendar->render();
|
||||
$output = preg_replace('/\r\n /u', '', $output);
|
||||
$this->assertContains($input, $output);
|
||||
}
|
||||
|
||||
public function testDescriptionWithNewLines()
|
||||
{
|
||||
$input = "new string \n new line \n new line \n new string";
|
||||
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2014-12-24'));
|
||||
$vEvent->setDtEnd(new \DateTime('2014-12-24'));
|
||||
$vEvent->setDescription($input);
|
||||
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
$output = $vCalendar->render();
|
||||
$this->assertContains(str_replace("\n", "\\n", $input), $output);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
class ParameterBagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testEscapeParamValue()
|
||||
{
|
||||
$propertyObject = new ParameterBag;
|
||||
|
||||
$this->assertEquals(
|
||||
'test string',
|
||||
$propertyObject->escapeParamValue('test string'),
|
||||
'No escaping necessary'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'"Containing \\"double-quotes\\""',
|
||||
$propertyObject->escapeParamValue('Containing "double-quotes"'),
|
||||
'Text contains double quotes'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'"Containing forbidden chars like a ;"',
|
||||
$propertyObject->escapeParamValue('Containing forbidden chars like a ;'),
|
||||
'Text with semicolon'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'"Containing forbidden chars like a :"',
|
||||
$propertyObject->escapeParamValue('Containing forbidden chars like a :'),
|
||||
'Text with colon'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal\Property;
|
||||
|
||||
class ArrayValueTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider arrayValuesProvider
|
||||
*/
|
||||
public function testArrayValue($values, $expectedOutput)
|
||||
{
|
||||
$arrayValue = new ArrayValue($values);
|
||||
|
||||
$this->assertEquals($expectedOutput, $arrayValue->getEscapedValue());
|
||||
}
|
||||
|
||||
public function arrayValuesProvider()
|
||||
{
|
||||
return array(
|
||||
array(array(), ''),
|
||||
array(array('Lorem'), 'Lorem'),
|
||||
array(array('Lorem', 'Ipsum'), 'Lorem,Ipsum'),
|
||||
array(array('Lorem', '"doublequotes"'), 'Lorem,\"doublequotes\"'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
class DescriptionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAllowsNewLines()
|
||||
{
|
||||
$testString = "New String \n New Line";
|
||||
$description = new Description($testString);
|
||||
|
||||
$this->assertEquals(
|
||||
str_replace("\n", "\\n", $testString),
|
||||
$description->getEscapedValue()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Eluceo\iCal\Property\Event\OrganizerTest
|
||||
*
|
||||
* @author Giulio Troccoli <giulio@troccoli.it>
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
/**
|
||||
* OrganizerTest
|
||||
*/
|
||||
class OrganizerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testOrganizerValueOnly()
|
||||
{
|
||||
$value = "MAILTO:name.lastname@example.com";
|
||||
$expected = "ORGANIZER:$value";
|
||||
|
||||
$vCalendar = $this->createCalendarWithOrganizer(
|
||||
new \Eluceo\iCal\Property\Event\Organizer($value)
|
||||
);
|
||||
|
||||
foreach (explode("\n", $vCalendar->render()) as $line)
|
||||
{
|
||||
if (preg_match('/^ORGANIZER[:;](.*)$/', $line)) {
|
||||
$this->assertEquals($expected, trim($line));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testOrganizerValueAndParameter()
|
||||
{
|
||||
$value = "MAILTO:name.lastname@example.com";
|
||||
$param = "Name LastName";
|
||||
$expected = "ORGANIZER;CN=$param:$value";
|
||||
|
||||
$vCalendar = $this->createCalendarWithOrganizer(
|
||||
new \Eluceo\iCal\Property\Event\Organizer($value, array('CN' => $param))
|
||||
);
|
||||
|
||||
foreach (explode("\n", $vCalendar->render()) as $line)
|
||||
{
|
||||
if (preg_match('/^ORGANIZER[:;](.*)$/', $line)) {
|
||||
$this->assertEquals($expected, trim($line));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Organizer $vOrganizer
|
||||
* @return \Eluceo\iCal\Component\Calendar
|
||||
*/
|
||||
private function createCalendarWithOrganizer(\Eluceo\iCal\Property\Event\Organizer $vOrganizer)
|
||||
{
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
$vEvent = new \Eluceo\iCal\Component\Event('123456');
|
||||
$vEvent->setOrganizer($vOrganizer);
|
||||
$vCalendar->addComponent($vEvent);
|
||||
return $vCalendar;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
class RecurrenceRuleTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Example taken from http://www.kanzaki.com/docs/ical/rrule.html
|
||||
*/
|
||||
public function testUntil()
|
||||
{
|
||||
$rule = new RecurrenceRule();
|
||||
$rule->setFreq(RecurrenceRule::FREQ_DAILY);
|
||||
$rule->setInterval(null);
|
||||
$rule->setUntil(new \DateTime('1997-12-24'));
|
||||
$this->assertEquals(
|
||||
'FREQ=DAILY;UNTIL=19971224T000000Z',
|
||||
$rule->getEscapedValue()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal\Property;
|
||||
|
||||
use Eluceo\iCal\Property\StringValue;
|
||||
|
||||
class StringValueTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testNoEscapeNeeded()
|
||||
{
|
||||
$stringValue = new StringValue('LOREM');
|
||||
|
||||
$this->assertEquals(
|
||||
'LOREM',
|
||||
$stringValue->getEscapedValue(),
|
||||
'No escaping necessary'
|
||||
);
|
||||
}
|
||||
|
||||
public function testValueContainsBackslash()
|
||||
{
|
||||
$stringValue = new StringValue('text contains backslash: \\');
|
||||
|
||||
$this->assertEquals(
|
||||
'text contains backslash: \\\\',
|
||||
$stringValue->getEscapedValue(),
|
||||
'Text contains backslash'
|
||||
);
|
||||
}
|
||||
|
||||
public function testEscapingDoubleQuotes()
|
||||
{
|
||||
$stringValue = new StringValue('text with "doublequotes" will be escaped');
|
||||
|
||||
$this->assertEquals(
|
||||
'text with \\"doublequotes\\" will be escaped',
|
||||
$stringValue->getEscapedValue(),
|
||||
'Escaping double quotes'
|
||||
);
|
||||
}
|
||||
|
||||
public function testEscapingSemicolonAndComma()
|
||||
{
|
||||
$stringValue = new StringValue('text with , and ; will also be escaped');
|
||||
|
||||
$this->assertEquals(
|
||||
'text with \\, and \\; will also be escaped',
|
||||
$stringValue->getEscapedValue(),
|
||||
'Escaping ; and ,'
|
||||
);
|
||||
}
|
||||
|
||||
public function testNewLineEscaping()
|
||||
{
|
||||
$stringValue = new StringValue("Text with new\n line");
|
||||
|
||||
$this->assertEquals(
|
||||
'Text with new\\n line',
|
||||
$stringValue->getEscapedValue(),
|
||||
'Escape new line to text'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
class PropertyBagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @todo Use Mocks instead of a real object!
|
||||
*/
|
||||
public function testPropertyAlreadyExistsOnAddingProperty()
|
||||
{
|
||||
$this->setExpectedException('\\Exception', "Property with name 'propName' already exists");
|
||||
|
||||
$propertyBag = new PropertyBag();
|
||||
$propertyBag->add(new Property('propName', ''));
|
||||
$propertyBag->add(new Property('propName', ''));
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
class PropertyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testPropertyWithSingleValue()
|
||||
{
|
||||
$property = new Property('DTSTAMP', '20131020T153112');
|
||||
$this->assertEquals(
|
||||
'DTSTAMP:20131020T153112',
|
||||
$property->toLine()
|
||||
);
|
||||
}
|
||||
|
||||
public function testPropertyWithValueAndParams()
|
||||
{
|
||||
$property = new Property('DTSTAMP', '20131020T153112', array('TZID' => 'Europe/Berlin'));
|
||||
$this->assertEquals(
|
||||
'DTSTAMP;TZID=Europe/Berlin:20131020T153112',
|
||||
$property->toLine()
|
||||
);
|
||||
}
|
||||
|
||||
public function testPropertyWithEscapedSingleValue()
|
||||
{
|
||||
$property = new Property('SOMEPROP', 'Escape me!"');
|
||||
$this->assertEquals(
|
||||
'SOMEPROP:Escape me!\\"',
|
||||
$property->toLine()
|
||||
);
|
||||
}
|
||||
|
||||
public function testPropertyWithEscapedValues()
|
||||
{
|
||||
$property = new Property('SOMEPROP', 'Escape me!"', array('TEST' => 'Lorem "test" ipsum'));
|
||||
$this->assertEquals(
|
||||
'SOMEPROP;TEST="Lorem \\"test\\" ipsum":Escape me!\\"',
|
||||
$property->toLine()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user