@@ -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->vo->getTimezone(), |
67 | 65 | $this->vo->getDisplayName() |
68 | 66 | )->render() |
69 | 67 | ) |
70 | 68 | ]; |
71 | 69 | |
72 | - if(!empty($this->vo->getDescription())) |
|
70 | + if (!empty($this->vo->getDescription())) |
|
73 | 71 | $props['{urn:ietf:params:xml:ns:caldav}calendar-description'] = $this->vo->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->vo->getDescription())) |
|
73 | - $props['{urn:ietf:params:xml:ns:caldav}calendar-description'] = $this->vo->getDescription(); |
|
72 | + if(!empty($this->vo->getDescription())) { |
|
73 | + $props['{urn:ietf:params:xml:ns:caldav}calendar-description'] = $this->vo->getDescription(); |
|
74 | + } |
|
74 | 75 | |
75 | 76 | return $service->write('{urn:ietf:params:xml:ns:caldav}mkcalendar', |
76 | 77 | [ |
@@ -54,7 +54,7 @@ |
||
54 | 54 | $this->description = $description; |
55 | 55 | $this->timezone = $timezone; |
56 | 56 | |
57 | - if(is_null($this->timezone)){ |
|
57 | + if (is_null($this->timezone)) { |
|
58 | 58 | $this->timezone = new DateTimeZone('UTC'); |
59 | 59 | } |
60 | 60 | } |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | * @param DateTimeZone $time_zone |
32 | 32 | * @return array |
33 | 33 | */ |
34 | - private static function calculateTimeRangeForTransitions(DateTimeZone $time_zone){ |
|
34 | + private static function calculateTimeRangeForTransitions(DateTimeZone $time_zone) { |
|
35 | 35 | |
36 | 36 | $now = new DateTime('now', $time_zone); |
37 | 37 | $year = $now->format('Y'); |
38 | - return [new DateTime('1/1/'.$year, $time_zone), new DateTime('1/1/'.($year + 1), $time_zone)]; |
|
38 | + return [new DateTime('1/1/'.$year, $time_zone), new DateTime('1/1/'.($year + 1), $time_zone)]; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | * @param int $former_offset |
44 | 44 | * @return DateTime |
45 | 45 | */ |
46 | - private static function convertStartDateFromUTC2Local(array $trans, $former_offset){ |
|
46 | + private static function convertStartDateFromUTC2Local(array $trans, $former_offset) { |
|
47 | 47 | $dt = new DateTime($trans['time'], new DateTimeZone('UTC')); |
48 | 48 | $hours = abs($former_offset); |
49 | 49 | // START TIME IS ON UTC and should be converted to local using former offset |
50 | - if($former_offset >= 0 ) |
|
50 | + if ($former_offset >= 0) |
|
51 | 51 | $dt->add(new DateInterval("PT{$hours}H")); |
52 | 52 | else |
53 | 53 | $dt->sub(new DateInterval("PT{$hours}H")); |
@@ -59,12 +59,11 @@ discard block |
||
59 | 59 | * @param DateTime $dt |
60 | 60 | * @return RecurrenceRule |
61 | 61 | */ |
62 | - private static function calculateRecurrenceRule(DateTime $dt){ |
|
63 | - $r_rule = new RecurrenceRule(); |
|
62 | + private static function calculateRecurrenceRule(DateTime $dt) { |
|
63 | + $r_rule = new RecurrenceRule(); |
|
64 | 64 | $r_rule->setFreq(RecurrenceRule::FREQ_YEARLY); |
65 | 65 | $r_rule->setByMonth(intval($dt->format('m'))); |
66 | - $r_rule->setByDay |
|
67 | - ( |
|
66 | + $r_rule->setByDay( |
|
68 | 67 | self::translate2ByDay($dt) |
69 | 68 | ); |
70 | 69 | return $r_rule; |
@@ -74,7 +73,7 @@ discard block |
||
74 | 73 | * @param $offset |
75 | 74 | * @return string |
76 | 75 | */ |
77 | - private static function calculateOffsetFrom($offset){ |
|
76 | + private static function calculateOffsetFrom($offset) { |
|
78 | 77 | return sprintf('%s%02d%02d', $offset >= 0 ? '+' : '-', abs($offset), abs(($offset - floor($offset)) * 60)); |
79 | 78 | } |
80 | 79 | |
@@ -82,7 +81,7 @@ discard block |
||
82 | 81 | * @param $offset |
83 | 82 | * @return string |
84 | 83 | */ |
85 | - private static function calculateOffsetTo($offset){ |
|
84 | + private static function calculateOffsetTo($offset) { |
|
86 | 85 | return sprintf('%s%02d%02d', $offset >= 0 ? '+' : '-', abs($offset), abs(($offset - floor($offset)) * 60)); |
87 | 86 | } |
88 | 87 | /** |
@@ -91,7 +90,7 @@ discard block |
||
91 | 90 | * @param bool $with_calendar_envelope |
92 | 91 | * @return Calendar|Timezone |
93 | 92 | */ |
94 | - public static function build(DateTimeZone $time_zone, $calendar_prod_id, $with_calendar_envelope = true){ |
|
93 | + public static function build(DateTimeZone $time_zone, $calendar_prod_id, $with_calendar_envelope = true) { |
|
95 | 94 | |
96 | 95 | // get all transitions for one current year and next |
97 | 96 | list($start_range, $end_range) = self::calculateTimeRangeForTransitions($time_zone); |
@@ -111,11 +110,11 @@ discard block |
||
111 | 110 | |
112 | 111 | // daylight saving time definition |
113 | 112 | if ($trans['isdst']) { |
114 | - $current_time_zone_rule = new TimezoneRule(TimezoneRule::TYPE_DAYLIGHT);; |
|
113 | + $current_time_zone_rule = new TimezoneRule(TimezoneRule::TYPE_DAYLIGHT); ; |
|
115 | 114 | } |
116 | 115 | // standard time definition |
117 | 116 | else { |
118 | - $current_time_zone_rule = new TimezoneRule(TimezoneRule::TYPE_STANDARD);; |
|
117 | + $current_time_zone_rule = new TimezoneRule(TimezoneRule::TYPE_STANDARD); ; |
|
119 | 118 | } |
120 | 119 | |
121 | 120 | if ($current_time_zone_rule) { |
@@ -136,7 +135,7 @@ discard block |
||
136 | 135 | } |
137 | 136 | |
138 | 137 | } |
139 | - if($with_calendar_envelope) { |
|
138 | + if ($with_calendar_envelope) { |
|
140 | 139 | $vCalendar = new Calendar(sprintf("'-//%s//EN'", $calendar_prod_id)); |
141 | 140 | $vCalendar->setTimezone($vTimezone); |
142 | 141 | return $vCalendar; |
@@ -156,25 +155,25 @@ discard block |
||
156 | 155 | * @param DateTime $dt) |
157 | 156 | * @return string |
158 | 157 | */ |
159 | - private static function translate2ByDay(DateTime $dt){ |
|
160 | - $day_name = substr(strtoupper($dt->format('D')), 0,2); |
|
158 | + private static function translate2ByDay(DateTime $dt) { |
|
159 | + $day_name = substr(strtoupper($dt->format('D')), 0, 2); |
|
161 | 160 | $ordinals = ['first', 'second', 'third', 'fourth', 'last']; |
162 | 161 | $day_nbr = 0; |
163 | 162 | $is_last = false; |
164 | 163 | |
165 | - foreach($ordinals as $idx => $ord){ |
|
164 | + foreach ($ordinals as $idx => $ord) { |
|
166 | 165 | $dt_n = self::buildOrdinalDateTime($ord, $dt); |
167 | - if($dt_n->format('Y-m-d') == $dt->format('Y-m-d')){ |
|
168 | - $day_nbr = $idx + 1; |
|
169 | - if($ord == 'last'){ |
|
166 | + if ($dt_n->format('Y-m-d') == $dt->format('Y-m-d')) { |
|
167 | + $day_nbr = $idx + 1; |
|
168 | + if ($ord == 'last') { |
|
170 | 169 | $is_last = true; |
171 | - $day_nbr = 1; |
|
170 | + $day_nbr = 1; |
|
172 | 171 | } |
173 | 172 | break; |
174 | 173 | } |
175 | 174 | } |
176 | 175 | |
177 | - return sprintf('%s%s%s', $is_last? '-':'', $day_nbr, $day_name); |
|
176 | + return sprintf('%s%s%s', $is_last ? '-' : '', $day_nbr, $day_name); |
|
178 | 177 | } |
179 | 178 | |
180 | 179 | /** |
@@ -182,15 +181,11 @@ discard block |
||
182 | 181 | * @param DateTime $dt |
183 | 182 | * @return DateTime |
184 | 183 | */ |
185 | - private static function buildOrdinalDateTime($ord, DateTime $dt){ |
|
186 | - return new DateTime |
|
187 | - ( |
|
188 | - date |
|
189 | - ("Y-m-d", |
|
190 | - strtotime |
|
191 | - ( |
|
192 | - sprintf |
|
193 | - ( |
|
184 | + private static function buildOrdinalDateTime($ord, DateTime $dt) { |
|
185 | + return new DateTime( |
|
186 | + date("Y-m-d", |
|
187 | + strtotime( |
|
188 | + sprintf( |
|
194 | 189 | self::GetOrdinalDayQuery, |
195 | 190 | $ord, |
196 | 191 | $dt->format('l'), |
@@ -47,10 +47,11 @@ |
||
47 | 47 | $dt = new DateTime($trans['time'], new DateTimeZone('UTC')); |
48 | 48 | $hours = abs($former_offset); |
49 | 49 | // START TIME IS ON UTC and should be converted to local using former offset |
50 | - if($former_offset >= 0 ) |
|
51 | - $dt->add(new DateInterval("PT{$hours}H")); |
|
52 | - else |
|
53 | - $dt->sub(new DateInterval("PT{$hours}H")); |
|
50 | + if($former_offset >= 0 ) { |
|
51 | + $dt->add(new DateInterval("PT{$hours}H")); |
|
52 | + } else { |
|
53 | + $dt->sub(new DateInterval("PT{$hours}H")); |
|
54 | + } |
|
54 | 55 | |
55 | 56 | return $dt; |
56 | 57 | } |
@@ -50,26 +50,26 @@ discard block |
||
50 | 50 | break; |
51 | 51 | case HttpMethods::Put: |
52 | 52 | $etag = $params[0]; |
53 | - if(empty($etag)){ |
|
54 | - return [ |
|
55 | - Headers::ContentType => ContentTypes::Calendar, |
|
56 | - Headers::IfNotMatch => '*', |
|
57 | - ]; |
|
58 | - } |
|
59 | - return [ |
|
60 | - Headers::ContentType => ContentTypes::Calendar, |
|
61 | - Headers::IfMatch => $etag |
|
62 | - ]; |
|
53 | + if(empty($etag)){ |
|
54 | + return [ |
|
55 | + Headers::ContentType => ContentTypes::Calendar, |
|
56 | + Headers::IfNotMatch => '*', |
|
57 | + ]; |
|
58 | + } |
|
59 | + return [ |
|
60 | + Headers::ContentType => ContentTypes::Calendar, |
|
61 | + Headers::IfMatch => $etag |
|
62 | + ]; |
|
63 | 63 | break; |
64 | 64 | } |
65 | 65 | return []; |
66 | 66 | } |
67 | 67 | /** |
68 | - * @param string $url |
|
69 | - * @param string $body |
|
70 | - * @param int $depth |
|
71 | - * @return Request |
|
72 | - */ |
|
68 | + * @param string $url |
|
69 | + * @param string $body |
|
70 | + * @param int $depth |
|
71 | + * @return Request |
|
72 | + */ |
|
73 | 73 | public static function createPropFindRequest($url , $body, $depth = 1){ |
74 | 74 | return new Request |
75 | 75 | ( |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @param string $etag |
159 | 159 | * @return Request |
160 | 160 | */ |
161 | - public static function createPutRequest($url, $body, $etag = null){ |
|
161 | + public static function createPutRequest($url, $body, $etag = null){ |
|
162 | 162 | return new Request |
163 | 163 | ( |
164 | 164 | HttpMethods::Put, |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @param array $params |
27 | 27 | * @return array |
28 | 28 | */ |
29 | - private static function createHeadersFor($http_method, array $params = []){ |
|
30 | - switch ($http_method){ |
|
29 | + private static function createHeadersFor($http_method, array $params = []) { |
|
30 | + switch ($http_method) { |
|
31 | 31 | case HttpMethods::PropFind: |
32 | 32 | case HttpMethods::Options: |
33 | 33 | case HttpMethods::Report: |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | break; |
40 | 40 | case HttpMethods::Delete: |
41 | 41 | $etag = $params[0]; |
42 | - if(!empty($etag)) |
|
42 | + if (!empty($etag)) |
|
43 | 43 | return [ |
44 | 44 | Headers::IfMatch => $params[0], |
45 | 45 | ]; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | break; |
54 | 54 | case HttpMethods::Put: |
55 | 55 | $etag = $params[0]; |
56 | - if(empty($etag)){ |
|
56 | + if (empty($etag)) { |
|
57 | 57 | return [ |
58 | 58 | Headers::ContentType => ContentTypes::Calendar, |
59 | 59 | Headers::IfNotMatch => '*', |
@@ -73,11 +73,10 @@ discard block |
||
73 | 73 | * @param int $depth |
74 | 74 | * @return Request |
75 | 75 | */ |
76 | - public static function createPropFindRequest($url , $body, $depth = 1){ |
|
77 | - return new Request |
|
78 | - ( |
|
76 | + public static function createPropFindRequest($url, $body, $depth = 1) { |
|
77 | + return new Request( |
|
79 | 78 | HttpMethods::PropFind, |
80 | - $url , |
|
79 | + $url, |
|
81 | 80 | self::createHeadersFor(HttpMethods::PropFind, [$depth]), |
82 | 81 | $body |
83 | 82 | ); |
@@ -88,9 +87,8 @@ discard block |
||
88 | 87 | * @param string $body |
89 | 88 | * @return Request |
90 | 89 | */ |
91 | - public static function createMakeCalendarRequest($url , $body){ |
|
92 | - return new Request |
|
93 | - ( |
|
90 | + public static function createMakeCalendarRequest($url, $body) { |
|
91 | + return new Request( |
|
94 | 92 | HttpMethods::MakeCalendar, |
95 | 93 | $url, |
96 | 94 | self::createHeadersFor(HttpMethods::MakeCalendar), |
@@ -103,9 +101,8 @@ discard block |
||
103 | 101 | * @param int $depth |
104 | 102 | * @return Request |
105 | 103 | */ |
106 | - public static function createOptionsRequest($url, $depth = 1){ |
|
107 | - return new Request |
|
108 | - ( |
|
104 | + public static function createOptionsRequest($url, $depth = 1) { |
|
105 | + return new Request( |
|
109 | 106 | HttpMethods::Options, |
110 | 107 | $url, |
111 | 108 | self::createHeadersFor(HttpMethods::Options, [$depth]) |
@@ -118,9 +115,8 @@ discard block |
||
118 | 115 | * @param int $depth |
119 | 116 | * @return Request |
120 | 117 | */ |
121 | - public static function createReportRequest($url , $body, $depth = 1){ |
|
122 | - return new Request |
|
123 | - ( |
|
118 | + public static function createReportRequest($url, $body, $depth = 1) { |
|
119 | + return new Request( |
|
124 | 120 | HttpMethods::Report, |
125 | 121 | $url, |
126 | 122 | self::createHeadersFor(HttpMethods::Report, [$depth]), |
@@ -133,9 +129,8 @@ discard block |
||
133 | 129 | * @param string $etag |
134 | 130 | * @return Request |
135 | 131 | */ |
136 | - public static function createDeleteRequest($url , $etag){ |
|
137 | - return new Request |
|
138 | - ( |
|
132 | + public static function createDeleteRequest($url, $etag) { |
|
133 | + return new Request( |
|
139 | 134 | HttpMethods::Delete, |
140 | 135 | $url, |
141 | 136 | self::createHeadersFor(HttpMethods::Delete, [$etag]) |
@@ -146,9 +141,8 @@ discard block |
||
146 | 141 | * @param string $url |
147 | 142 | * @return Request |
148 | 143 | */ |
149 | - public static function createGetRequest($url){ |
|
150 | - return new Request |
|
151 | - ( |
|
144 | + public static function createGetRequest($url) { |
|
145 | + return new Request( |
|
152 | 146 | HttpMethods::Get, |
153 | 147 | $url, |
154 | 148 | self::createHeadersFor(HttpMethods::Get) |
@@ -161,9 +155,8 @@ discard block |
||
161 | 155 | * @param string $etag |
162 | 156 | * @return Request |
163 | 157 | */ |
164 | - public static function createPutRequest($url, $body, $etag = null){ |
|
165 | - return new Request |
|
166 | - ( |
|
158 | + public static function createPutRequest($url, $body, $etag = null) { |
|
159 | + return new Request( |
|
167 | 160 | HttpMethods::Put, |
168 | 161 | $url, |
169 | 162 | self::createHeadersFor(HttpMethods::Put, [$etag]), |
@@ -39,10 +39,11 @@ |
||
39 | 39 | break; |
40 | 40 | case HttpMethods::Delete: |
41 | 41 | $etag = $params[0]; |
42 | - if(!empty($etag)) |
|
43 | - return [ |
|
42 | + if(!empty($etag)) { |
|
43 | + return [ |
|
44 | 44 | Headers::IfMatch => $params[0], |
45 | 45 | ]; |
46 | + } |
|
46 | 47 | return []; |
47 | 48 | break; |
48 | 49 | case HttpMethods::MakeCalendar: |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | protected function parse() |
27 | 27 | { |
28 | - if(isset($this->content['response'])){ |
|
28 | + if (isset($this->content['response'])) { |
|
29 | 29 | |
30 | - if(isset($this->content['response']['propstat'])) { |
|
30 | + if (isset($this->content['response']['propstat'])) { |
|
31 | 31 | // its a collection with one single element |
32 | 32 | $single_resource = $this->buildSingleResponse(); |
33 | 33 | $single_resource->setContent(['response' => $this->content['response']]); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * @return GenericSinglePROPFINDCalDAVResponse[] |
50 | 50 | */ |
51 | - public function getResponses(){ |
|
51 | + public function getResponses() { |
|
52 | 52 | return $this->responses; |
53 | 53 | } |
54 | 54 |
@@ -21,7 +21,7 @@ |
||
21 | 21 | /** |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public function getVCard(){ |
|
24 | + public function getVCard() { |
|
25 | 25 | return isset($this->found_props['calendar-data']) ? $this->found_props['calendar-data'] : null; |
26 | 26 | } |
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -21,7 +21,7 @@ |
||
21 | 21 | /** |
22 | 22 | * @return bool |
23 | 23 | */ |
24 | - public function isSuccessFull(){ |
|
24 | + public function isSuccessFull() { |
|
25 | 25 | return $this->code == HttpResponse::HttpCodeNoContent; |
26 | 26 | } |
27 | 27 | } |
28 | 28 | \ No newline at end of file |