88use Spatie \CalendarLinks \Link ;
99
1010/**
11+ * @api
1112 * @see https://icalendar.org/RFC-Specifications/iCalendar-RFC-5545/
1213 * @psalm-type IcsOptions = array{UID?: string, URL?: string, PRODID?: string, REMINDER?: array{DESCRIPTION?: string, TIME?: \DateTimeInterface}}
1314 * @psalm-type IcsPresentationOptions = array{format?: self::FORMAT_*}
1415 */
1516class Ics implements Generator
1617{
17- public const FORMAT_HTML = 'html ' ;
18- public const FORMAT_FILE = 'file ' ;
18+ public const string FORMAT_HTML = 'html ' ;
19+ public const string FORMAT_FILE = 'file ' ;
1920
2021 /** @see https://www.php.net/manual/en/function.date.php */
2122 protected string $ dateFormat = 'Ymd ' ;
@@ -39,6 +40,7 @@ public function __construct(array $options = [], array $presentationOptions = []
3940 }
4041
4142 /** @inheritDoc */
43+ #[\Override]
4244 public function generate (Link $ link ): string
4345 {
4446 $ url = [
@@ -56,7 +58,7 @@ public function generate(Link $link): string
5658 if ($ link ->allDay ) {
5759 $ url [] = 'DTSTAMP: ' .gmdate ($ this ->dateTimeFormat , $ link ->from ->getTimestamp ());
5860 $ url [] = 'DTSTART;VALUE=DATE: ' .$ link ->from ->format ($ dateTimeFormat );
59- $ url [] = 'DURATION:P ' .(max (1 , $ link ->from ->diff ($ link ->to )->days )).'D ' ;
61+ $ url [] = 'DURATION:P ' .(max (1 , ( int ) $ link ->from ->diff ($ link ->to )->days )).'D ' ;
6062 } else {
6163 $ url [] = 'DTSTAMP: ' .gmdate ($ dateTimeFormat , $ link ->from ->getTimestamp ());
6264 $ url [] = 'DTSTART: ' .gmdate ($ dateTimeFormat , $ link ->from ->getTimestamp ());
0 commit comments