Conditions | 4 |
Paths | 8 |
Total Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
13 | public function generate(Link $link): string |
||
14 | { |
||
15 | $url = ['data:text/calendar;charset=utf8,', |
||
16 | 'BEGIN:VCALENDAR', |
||
17 | 'VERSION:2.0', |
||
18 | 'BEGIN:VEVENT', |
||
19 | 'SUMMARY:'.$link->title, ]; |
||
20 | |||
21 | if ($link->allDay) { |
||
22 | $dateTimeFormat = 'Ymd'; |
||
23 | $url[] = 'DTSTART:'.$link->from->format($dateTimeFormat); |
||
24 | $url[] = 'DTEND:'.$link->to->format($dateTimeFormat); |
||
25 | } else { |
||
26 | $dateTimeFormat = "e:Ymd\THis"; |
||
27 | $url[] = 'DTSTART;TZID='.$link->from->format($dateTimeFormat); |
||
28 | $url[] = 'DTEND;TZID='.$link->to->format($dateTimeFormat); |
||
29 | } |
||
30 | |||
31 | if ($link->description) { |
||
32 | $url[] = 'DESCRIPTION:'.$this->escapeString($link->description); |
||
33 | } |
||
34 | if ($link->address) { |
||
35 | $url[] = 'LOCATION:'.$this->escapeString($link->address); |
||
36 | } |
||
37 | |||
38 | $url[] = 'END:VEVENT'; |
||
39 | $url[] = 'END:VCALENDAR'; |
||
40 | $redirectLink = implode('%0A', $url); |
||
41 | |||
42 | return $redirectLink; |
||
43 | } |
||
44 | |||
50 |