@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param bool $with_calendar_envelope |
31 | 31 | * @return Calendar|Timezone |
32 | 32 | */ |
33 | - public static function build(DateTimeZone $time_zone, $calendar_prod_id, $with_calendar_envelope = true){ |
|
33 | + public static function build(DateTimeZone $time_zone, $calendar_prod_id, $with_calendar_envelope = true) { |
|
34 | 34 | |
35 | 35 | $now = new DateTime('now', $time_zone); |
36 | 36 | $year = $now->format('Y'); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | // daylight saving time definition |
57 | 57 | if ($trans['isdst']) { |
58 | - $dst = new \Eluceo\iCal\Component\TimezoneRule(\Eluceo\iCal\Component\TimezoneRule::TYPE_DAYLIGHT); |
|
58 | + $dst = new \Eluceo\iCal\Component\TimezoneRule(\Eluceo\iCal\Component\TimezoneRule::TYPE_DAYLIGHT); |
|
59 | 59 | $current_time_zone_rule = $dst; |
60 | 60 | } |
61 | 61 | // standard time definition |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $offset = $trans['offset'] / 3600; |
70 | 70 | // DATETIME S |
71 | 71 | $hours = abs($former_offset); |
72 | - if($former_offset >= 0 ) |
|
72 | + if ($former_offset >= 0) |
|
73 | 73 | $dt->add(new DateInterval("PT{$hours}H")); |
74 | 74 | else |
75 | 75 | $dt->sub(new DateInterval("PT{$hours}H")); |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | $r_rule = new \Eluceo\iCal\Property\Event\RecurrenceRule(); |
87 | 87 | $r_rule->setFreq(\Eluceo\iCal\Property\Event\RecurrenceRule::FREQ_YEARLY); |
88 | 88 | $r_rule->setByMonth(intval($dt->format('m'))); |
89 | - $r_rule->setByDay |
|
90 | - ( |
|
89 | + $r_rule->setByDay( |
|
91 | 90 | self::translate2ByDay($dt) |
92 | 91 | ); |
93 | 92 | $current_time_zone_rule->setRecurrenceRule($r_rule); |
@@ -95,7 +94,7 @@ discard block |
||
95 | 94 | } |
96 | 95 | |
97 | 96 | } |
98 | - if($with_calendar_envelope) { |
|
97 | + if ($with_calendar_envelope) { |
|
99 | 98 | $vCalendar = new Calendar(sprintf("'-//%s//EN'", $calendar_prod_id)); |
100 | 99 | $vCalendar->setTimezone($vTimezone); |
101 | 100 | return $vCalendar; |
@@ -115,25 +114,25 @@ discard block |
||
115 | 114 | * @param DateTime $dt) |
116 | 115 | * @return string |
117 | 116 | */ |
118 | - private static function translate2ByDay(DateTime $dt){ |
|
119 | - $day_name = substr(strtoupper($dt->format('D')), 0,2); |
|
117 | + private static function translate2ByDay(DateTime $dt) { |
|
118 | + $day_name = substr(strtoupper($dt->format('D')), 0, 2); |
|
120 | 119 | $ordinals = ['first', 'second', 'third', 'fourth', 'last']; |
121 | 120 | $day_nbr = 0; |
122 | 121 | $is_last = false; |
123 | 122 | |
124 | - foreach($ordinals as $idx => $ord){ |
|
123 | + foreach ($ordinals as $idx => $ord) { |
|
125 | 124 | $dt_n = self::buildOrdinalDateTime($ord, $dt); |
126 | - if($dt_n->format('Y-m-d') == $dt->format('Y-m-d')){ |
|
127 | - $day_nbr = $idx + 1; |
|
128 | - if($ord == 'last'){ |
|
125 | + if ($dt_n->format('Y-m-d') == $dt->format('Y-m-d')) { |
|
126 | + $day_nbr = $idx + 1; |
|
127 | + if ($ord == 'last') { |
|
129 | 128 | $is_last = true; |
130 | - $day_nbr = 1; |
|
129 | + $day_nbr = 1; |
|
131 | 130 | } |
132 | 131 | break; |
133 | 132 | } |
134 | 133 | } |
135 | 134 | |
136 | - return sprintf('%s%s%s', $is_last? '-':'', $day_nbr, $day_name); |
|
135 | + return sprintf('%s%s%s', $is_last ? '-' : '', $day_nbr, $day_name); |
|
137 | 136 | } |
138 | 137 | |
139 | 138 | /** |
@@ -141,15 +140,11 @@ discard block |
||
141 | 140 | * @param DateTime $dt |
142 | 141 | * @return DateTime |
143 | 142 | */ |
144 | - private static function buildOrdinalDateTime($ord, DateTime $dt){ |
|
145 | - return new DateTime |
|
146 | - ( |
|
147 | - date |
|
148 | - ("Y-m-d", |
|
149 | - strtotime |
|
150 | - ( |
|
151 | - sprintf |
|
152 | - ( |
|
143 | + private static function buildOrdinalDateTime($ord, DateTime $dt) { |
|
144 | + return new DateTime( |
|
145 | + date("Y-m-d", |
|
146 | + strtotime( |
|
147 | + sprintf( |
|
153 | 148 | self::GetOrdinalDayQuery, |
154 | 149 | $ord, |
155 | 150 | $dt->format('l'), |
@@ -69,10 +69,11 @@ |
||
69 | 69 | $offset = $trans['offset'] / 3600; |
70 | 70 | // DATETIME S |
71 | 71 | $hours = abs($former_offset); |
72 | - if($former_offset >= 0 ) |
|
73 | - $dt->add(new DateInterval("PT{$hours}H")); |
|
74 | - else |
|
75 | - $dt->sub(new DateInterval("PT{$hours}H")); |
|
72 | + if($former_offset >= 0 ) { |
|
73 | + $dt->add(new DateInterval("PT{$hours}H")); |
|
74 | + } else { |
|
75 | + $dt->sub(new DateInterval("PT{$hours}H")); |
|
76 | + } |
|
76 | 77 | $current_time_zone_rule->setDtStart($dt); |
77 | 78 | $current_time_zone_rule->setTzOffsetFrom(sprintf('%s%02d%02d', $former_offset >= 0 ? '+' : '-', abs($former_offset), abs(($former_offset - floor($former_offset)) * 60))); |
78 | 79 | $current_time_zone_rule->setTzOffsetTo(sprintf('%s%02d%02d', $offset >= 0 ? '+' : '-', abs($offset), abs(($offset - floor($offset)) * 60))); |
@@ -21,11 +21,11 @@ |
||
21 | 21 | final class RequestFactory |
22 | 22 | { |
23 | 23 | /** |
24 | - * @param string $url |
|
25 | - * @param string $body |
|
26 | - * @param int $depth |
|
27 | - * @return Request |
|
28 | - */ |
|
24 | + * @param string $url |
|
25 | + * @param string $body |
|
26 | + * @param int $depth |
|
27 | + * @return Request |
|
28 | + */ |
|
29 | 29 | static function createPropFindRequest($url , $body, $depth = 1){ |
30 | 30 | return new Request('PROPFIND', $url , [ |
31 | 31 | 'Depth' => $depth, |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @param int $depth |
27 | 27 | * @return Request |
28 | 28 | */ |
29 | - static function createPropFindRequest($url , $body, $depth = 1){ |
|
30 | - return new Request('PROPFIND', $url , [ |
|
29 | + static function createPropFindRequest($url, $body, $depth = 1) { |
|
30 | + return new Request('PROPFIND', $url, [ |
|
31 | 31 | 'Depth' => $depth, |
32 | 32 | "Prefer" => "return-minimal", |
33 | 33 | "Content-Type" => ContentTypes::ContentTypeXml |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * @param string $body |
42 | 42 | * @return Request |
43 | 43 | */ |
44 | - static function createMakeCalendarRequest($url , $body){ |
|
45 | - return new Request('MKCALENDAR', $url , [ |
|
44 | + static function createMakeCalendarRequest($url, $body) { |
|
45 | + return new Request('MKCALENDAR', $url, [ |
|
46 | 46 | "Content-Type" => ContentTypes::ContentTypeXml |
47 | 47 | ], |
48 | 48 | $body |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * @param int $depth |
55 | 55 | * @return Request |
56 | 56 | */ |
57 | - static function createOptionsRequest($url, $depth = 1){ |
|
58 | - return new Request('OPTIONS', $url , [ |
|
57 | + static function createOptionsRequest($url, $depth = 1) { |
|
58 | + return new Request('OPTIONS', $url, [ |
|
59 | 59 | 'Depth' => $depth, |
60 | 60 | "Prefer" => "return-minimal", |
61 | 61 | "Content-Type" => ContentTypes::ContentTypeXml |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @param int $depth |
69 | 69 | * @return Request |
70 | 70 | */ |
71 | - static function createReportRequest($url , $body, $depth = 1){ |
|
72 | - return new Request('REPORT', $url , [ |
|
71 | + static function createReportRequest($url, $body, $depth = 1) { |
|
72 | + return new Request('REPORT', $url, [ |
|
73 | 73 | 'Depth' => $depth, |
74 | 74 | "Prefer" => "return-minimal", |
75 | 75 | "Content-Type" => ContentTypes::ContentTypeXml |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | * @param string $etag |
84 | 84 | * @return Request |
85 | 85 | */ |
86 | - static function createDeleteRequest($url , $etag){ |
|
87 | - return new Request('DELETE', $url , [ |
|
86 | + static function createDeleteRequest($url, $etag) { |
|
87 | + return new Request('DELETE', $url, [ |
|
88 | 88 | "If-Match" => $etag |
89 | 89 | ]); |
90 | 90 | } |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @param string $url |
94 | 94 | * @return Request |
95 | 95 | */ |
96 | - static function createGetRequest($url){ |
|
97 | - return new Request('GET', $url , [ |
|
96 | + static function createGetRequest($url) { |
|
97 | + return new Request('GET', $url, [ |
|
98 | 98 | ]); |
99 | 99 | } |
100 | 100 | |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | * @param string $etag |
105 | 105 | * @return Request |
106 | 106 | */ |
107 | - static function createPutRequest($url, $body, $etag = null){ |
|
107 | + static function createPutRequest($url, $body, $etag = null) { |
|
108 | 108 | $headers = [ |
109 | 109 | "Content-Type" => ContentTypes::ContentTypeCalendar, |
110 | 110 | ]; |
111 | 111 | |
112 | - if(empty($etag)){ |
|
112 | + if (empty($etag)) { |
|
113 | 113 | $headers["If-None-Match"] = "*"; |
114 | 114 | } |
115 | - else{ |
|
115 | + else { |
|
116 | 116 | $headers["If-Match"] = $etag; |
117 | 117 | } |
118 | 118 | |
119 | - return new Request('PUT', $url, $headers, $body); |
|
119 | + return new Request('PUT', $url, $headers, $body); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | } |
123 | 123 | \ No newline at end of file |
@@ -111,8 +111,7 @@ |
||
111 | 111 | |
112 | 112 | if(empty($etag)){ |
113 | 113 | $headers["If-None-Match"] = "*"; |
114 | - } |
|
115 | - else{ |
|
114 | + } else{ |
|
116 | 115 | $headers["If-Match"] = $etag; |
117 | 116 | } |
118 | 117 |
@@ -59,7 +59,7 @@ |
||
59 | 59 | |
60 | 60 | if($time_zone->getName() == 'UTC'){ |
61 | 61 | $event->setUseUtc(true) |
62 | - ->setUseTimezone(false); |
|
62 | + ->setUseTimezone(false); |
|
63 | 63 | } |
64 | 64 | else{ |
65 | 65 | $event->setUseUtc(false) |
@@ -57,16 +57,16 @@ |
||
57 | 57 | ->setDescription(strip_tags($this->dto->getDescription())) |
58 | 58 | ->setDescriptionHTML($this->dto->getDescription()); |
59 | 59 | |
60 | - if($time_zone->getName() == 'UTC'){ |
|
60 | + if ($time_zone->getName() == 'UTC') { |
|
61 | 61 | $event->setUseUtc(true) |
62 | 62 | ->setUseTimezone(false); |
63 | 63 | } |
64 | - else{ |
|
64 | + else { |
|
65 | 65 | $event->setUseUtc(false) |
66 | 66 | ->setUseTimezone(true); |
67 | 67 | } |
68 | 68 | |
69 | - if(!empty($this->dto->getLocationTitle())){ |
|
69 | + if (!empty($this->dto->getLocationTitle())) { |
|
70 | 70 | $geo = sprintf("%s;%s", $this->dto->getLocationLat(), $this->dto->getLocationLng()); |
71 | 71 | $event->setLocation($this->dto->getLocationTitle(), $this->dto->getLocationTitle(), $geo); |
72 | 72 | } |
@@ -60,8 +60,7 @@ |
||
60 | 60 | if($time_zone->getName() == 'UTC'){ |
61 | 61 | $event->setUseUtc(true) |
62 | 62 | ->setUseTimezone(false); |
63 | - } |
|
64 | - else{ |
|
63 | + } else{ |
|
65 | 64 | $event->setUseUtc(false) |
66 | 65 | ->setUseTimezone(true); |
67 | 66 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function __construct(){ |
23 | 23 | $this->properties = [ |
24 | - '{DAV:}current-user-principal' |
|
24 | + '{DAV:}current-user-principal' |
|
25 | 25 | ]; |
26 | 26 | } |
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -19,7 +19,7 @@ |
||
19 | 19 | final class UserPrincipalRequest extends AbstractPropFindWebDAVRequest |
20 | 20 | { |
21 | 21 | |
22 | - public function __construct(){ |
|
22 | + public function __construct() { |
|
23 | 23 | $this->properties = [ |
24 | 24 | '{DAV:}current-user-principal' |
25 | 25 | ]; |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | public function getContent() |
39 | 39 | { |
40 | - $service = new Service(); |
|
40 | + $service = new Service(); |
|
41 | 41 | |
42 | 42 | $service->namespaceMap = [ |
43 | 43 | 'DAV:' => 'D', |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * CalendarMultiGetRequest constructor. |
29 | 29 | * @param array $hrefs |
30 | 30 | */ |
31 | - public function __construct(array $hrefs){ |
|
31 | + public function __construct(array $hrefs) { |
|
32 | 32 | $this->hrefs = $hrefs; |
33 | 33 | } |
34 | 34 | |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | 'DAV:' => 'D', |
44 | 44 | 'urn:ietf:params:xml:ns:caldav' => 'C', |
45 | 45 | ]; |
46 | - $nodes = [ |
|
46 | + $nodes = [ |
|
47 | 47 | '{DAV:}prop' => [ |
48 | 48 | '{DAV:}getetag' => '', |
49 | 49 | '{urn:ietf:params:xml:ns:caldav}calendar-data' => '' |
50 | 50 | ], |
51 | 51 | ]; |
52 | 52 | // set hrefs |
53 | - foreach ($this->hrefs as $href){ |
|
53 | + foreach ($this->hrefs as $href) { |
|
54 | 54 | $nodes[] = ['name' => '{DAV:}href', 'value' => $href]; |
55 | 55 | } |
56 | 56 | return $service->write('{urn:ietf:params:xml:ns:caldav}calendar-multiget', $nodes); |
@@ -49,15 +49,15 @@ |
||
49 | 49 | $filter = []; |
50 | 50 | $props = []; |
51 | 51 | |
52 | - if($this->filter->useGetETags()){ |
|
52 | + if ($this->filter->useGetETags()) { |
|
53 | 53 | $props['{DAV:}getetag'] = ''; |
54 | 54 | } |
55 | 55 | |
56 | - if($this->filter->useGetCalendarData()){ |
|
56 | + if ($this->filter->useGetCalendarData()) { |
|
57 | 57 | $props['{urn:ietf:params:xml:ns:caldav}calendar-data'] = ''; |
58 | 58 | } |
59 | 59 | |
60 | - $nodes = [ |
|
60 | + $nodes = [ |
|
61 | 61 | '{DAV:}prop' => [ |
62 | 62 | $props |
63 | 63 | ], |
@@ -59,17 +59,15 @@ |
||
59 | 59 | 'attributes' => ['name' => 'VEVENT'] |
60 | 60 | ] |
61 | 61 | ], |
62 | - '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => new Cdata |
|
63 | - ( |
|
64 | - ICalTimeZoneBuilder::build |
|
65 | - ( |
|
62 | + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => new Cdata( |
|
63 | + ICalTimeZoneBuilder::build( |
|
66 | 64 | $this->dto->getTimezone(), |
67 | 65 | $this->dto->getDisplayName() |
68 | 66 | )->render() |
69 | 67 | ) |
70 | 68 | ]; |
71 | 69 | |
72 | - if(!empty($this->dto->getDescription())) |
|
70 | + if (!empty($this->dto->getDescription())) |
|
73 | 71 | $props['{urn:ietf:params:xml:ns:caldav}calendar-description'] = $this->dto->getDescription(); |
74 | 72 | |
75 | 73 | return $service->write('{urn:ietf:params:xml:ns:caldav}mkcalendar', |
@@ -69,8 +69,9 @@ |
||
69 | 69 | ) |
70 | 70 | ]; |
71 | 71 | |
72 | - if(!empty($this->dto->getDescription())) |
|
73 | - $props['{urn:ietf:params:xml:ns:caldav}calendar-description'] = $this->dto->getDescription(); |
|
72 | + if(!empty($this->dto->getDescription())) { |
|
73 | + $props['{urn:ietf:params:xml:ns:caldav}calendar-description'] = $this->dto->getDescription(); |
|
74 | + } |
|
74 | 75 | |
75 | 76 | return $service->write('{urn:ietf:params:xml:ns:caldav}mkcalendar', |
76 | 77 | [ |
@@ -94,8 +94,7 @@ discard block |
||
94 | 94 | * @param string $location_lat |
95 | 95 | * @param string $location_lng |
96 | 96 | */ |
97 | - public function __construct |
|
98 | - ( |
|
97 | + public function __construct( |
|
99 | 98 | $prod_id, |
100 | 99 | $title, |
101 | 100 | $description, |
@@ -121,7 +120,7 @@ discard block |
||
121 | 120 | $this->location_lat = $location_lat; |
122 | 121 | $this->location_lng = $location_lng; |
123 | 122 | $this->time_zone = $time_zone; |
124 | - if(is_null( $this->time_zone)){ |
|
123 | + if (is_null($this->time_zone)) { |
|
125 | 124 | $this->time_zone = new DateTimeZone('UTC'); |
126 | 125 | } |
127 | 126 | } |
@@ -129,7 +128,7 @@ discard block |
||
129 | 128 | /** |
130 | 129 | * @param string $uid |
131 | 130 | */ |
132 | - public function setUID($uid){ |
|
131 | + public function setUID($uid) { |
|
133 | 132 | $this->uid = $uid; |
134 | 133 | } |
135 | 134 | |
@@ -216,7 +215,7 @@ discard block |
||
216 | 215 | /** |
217 | 216 | * @return DateTimeZone |
218 | 217 | */ |
219 | - public function getTimeZone(){ |
|
218 | + public function getTimeZone() { |
|
220 | 219 | return $this->time_zone; |
221 | 220 | } |
222 | 221 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | final class GetCalendarsRequest extends AbstractPropFindWebDAVRequest |
19 | 19 | { |
20 | - public function __construct(){ |
|
20 | + public function __construct() { |
|
21 | 21 | $this->properties = [ |
22 | 22 | '{DAV:}resourcetype', |
23 | 23 | '{DAV:}displayname', |