@@ -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 | } |
@@ -40,7 +40,9 @@ discard block |
||
| 40 | 40 | * @return CalDAVRequestFactory |
| 41 | 41 | */ |
| 42 | 42 | public static function getInstance(){ |
| 43 | - if(is_null(self::$instance)) self::$instance = new CalDAVRequestFactory(); |
|
| 43 | + if(is_null(self::$instance)) { |
|
| 44 | + self::$instance = new CalDAVRequestFactory(); |
|
| 45 | + } |
|
| 44 | 46 | return self::$instance; |
| 45 | 47 | } |
| 46 | 48 | |
@@ -61,28 +63,34 @@ discard block |
||
| 61 | 63 | case self::CalendarRequestType: |
| 62 | 64 | return new GetCalendarRequest(); |
| 63 | 65 | case self::CalendarSyncRequestType: |
| 64 | - if(count($params) == 0 ) |
|
| 65 | - throw new \InvalidArgumentException(); |
|
| 66 | + if(count($params) == 0 ) { |
|
| 67 | + throw new \InvalidArgumentException(); |
|
| 68 | + } |
|
| 66 | 69 | return new CalendarSyncRequest($params[0]); |
| 67 | 70 | case self::CalendarMultiGetRequestType: |
| 68 | - if(count($params) == 0 ) |
|
| 69 | - throw new \InvalidArgumentException(); |
|
| 71 | + if(count($params) == 0 ) { |
|
| 72 | + throw new \InvalidArgumentException(); |
|
| 73 | + } |
|
| 70 | 74 | return new CalendarMultiGetRequest($params[0]); |
| 71 | 75 | case self::CalendarQueryRequestType: |
| 72 | - if(count($params) == 0 ) |
|
| 73 | - throw new \InvalidArgumentException(); |
|
| 76 | + if(count($params) == 0 ) { |
|
| 77 | + throw new \InvalidArgumentException(); |
|
| 78 | + } |
|
| 74 | 79 | return new CalendarQueryRequest($params[0]); |
| 75 | 80 | case self::CalendarCreateRequestType: |
| 76 | - if(count($params) == 0 ) |
|
| 77 | - throw new \InvalidArgumentException(); |
|
| 81 | + if(count($params) == 0 ) { |
|
| 82 | + throw new \InvalidArgumentException(); |
|
| 83 | + } |
|
| 78 | 84 | return new CalendarCreateRequest($params[0]); |
| 79 | 85 | case self::EventCreateRequestType: |
| 80 | - if(count($params) == 0 ) |
|
| 81 | - throw new \InvalidArgumentException(); |
|
| 86 | + if(count($params) == 0 ) { |
|
| 87 | + throw new \InvalidArgumentException(); |
|
| 88 | + } |
|
| 82 | 89 | return new EventCreateRequest($params[0]); |
| 83 | 90 | case self::EventUpdateRequestType: |
| 84 | - if(count($params) == 0 ) |
|
| 85 | - throw new \InvalidArgumentException(); |
|
| 91 | + if(count($params) == 0 ) { |
|
| 92 | + throw new \InvalidArgumentException(); |
|
| 93 | + } |
|
| 86 | 94 | return new EventUpdateRequest($params[0]); |
| 87 | 95 | } |
| 88 | 96 | return null; |
@@ -41,8 +41,12 @@ discard block |
||
| 41 | 41 | protected function parse() |
| 42 | 42 | { |
| 43 | 43 | |
| 44 | - if (!$this->isValid()) throw new NotValidGenericSingleCalDAVResponseException(); |
|
| 45 | - if (!isset($this->content['response']['propstat'])) return $this; |
|
| 44 | + if (!$this->isValid()) { |
|
| 45 | + throw new NotValidGenericSingleCalDAVResponseException(); |
|
| 46 | + } |
|
| 47 | + if (!isset($this->content['response']['propstat'])) { |
|
| 48 | + return $this; |
|
| 49 | + } |
|
| 46 | 50 | if (isset($this->content['response']['propstat']['prop']) && isset($this->content['response']['propstat']['status'])) { |
| 47 | 51 | // all props found |
| 48 | 52 | $status = $this->content['response']['propstat']['status']; |
@@ -62,13 +66,17 @@ discard block |
||
| 62 | 66 | // multi props ( found or not found) |
| 63 | 67 | foreach ($this->content['response']['propstat'] as $propstat) { |
| 64 | 68 | |
| 65 | - if (!isset($propstat['status']) || !isset($propstat['prop'])) continue; |
|
| 69 | + if (!isset($propstat['status']) || !isset($propstat['prop'])) { |
|
| 70 | + continue; |
|
| 71 | + } |
|
| 66 | 72 | |
| 67 | - if ($propstat['status'] == AbstractCalDAVResponse::HttpOKStatus) |
|
| 68 | - $this->found_props = $propstat['prop']; |
|
| 73 | + if ($propstat['status'] == AbstractCalDAVResponse::HttpOKStatus) { |
|
| 74 | + $this->found_props = $propstat['prop']; |
|
| 75 | + } |
|
| 69 | 76 | |
| 70 | - if ($propstat['status'] == AbstractCalDAVResponse::HttpNotFoundStatus) |
|
| 71 | - $this->not_found_props = $propstat['prop']; |
|
| 77 | + if ($propstat['status'] == AbstractCalDAVResponse::HttpNotFoundStatus) { |
|
| 78 | + $this->not_found_props = $propstat['prop']; |
|
| 79 | + } |
|
| 72 | 80 | } |
| 73 | 81 | return $this; |
| 74 | 82 | } |
@@ -46,8 +46,9 @@ |
||
| 46 | 46 | $this->server_url = $server_url; |
| 47 | 47 | if(!empty($this->body)) { |
| 48 | 48 | $this->xml = simplexml_load_string($this->body, 'SimpleXMLElement', LIBXML_NOCDATA); |
| 49 | - if($this->xml === FALSE) |
|
| 50 | - throw new XMLResponseParseException(); |
|
| 49 | + if($this->xml === FALSE) { |
|
| 50 | + throw new XMLResponseParseException(); |
|
| 51 | + } |
|
| 51 | 52 | $this->content = $this->toAssocArray($this->xml); |
| 52 | 53 | $this->parse(); |
| 53 | 54 | } |
@@ -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 | [ |
@@ -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 | } |
@@ -143,8 +143,7 @@ |
||
| 143 | 143 | 'auth' => [$this->user, $this->password, $this->authtype], |
| 144 | 144 | 'timeout' => $this->timeout |
| 145 | 145 | ]); |
| 146 | - } |
|
| 147 | - catch (ClientException $ex){ |
|
| 146 | + } catch (ClientException $ex){ |
|
| 148 | 147 | switch($ex->getCode()){ |
| 149 | 148 | case 401: |
| 150 | 149 | throw new UserUnAuthorizedException(); |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | public function getUpdates(){ |
| 40 | 40 | $res = []; |
| 41 | 41 | foreach ($this->responses as $entity){ |
| 42 | - if($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpOKStatus) continue; |
|
| 42 | + if($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpOKStatus) { |
|
| 43 | + continue; |
|
| 44 | + } |
|
| 43 | 45 | $res[] = $entity; |
| 44 | 46 | } |
| 45 | 47 | return $res; |
@@ -51,7 +53,9 @@ discard block |
||
| 51 | 53 | public function getDeletes(){ |
| 52 | 54 | $res = []; |
| 53 | 55 | foreach ($this->responses as $entity){ |
| 54 | - if($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpNotFoundStatus) continue; |
|
| 56 | + if($entity instanceof ETagEntityResponse && $entity->getStatus() != HttpResponse::HttpNotFoundStatus) { |
|
| 57 | + continue; |
|
| 58 | + } |
|
| 55 | 59 | $res[] = $entity; |
| 56 | 60 | } |
| 57 | 61 | return $res; |
@@ -53,8 +53,9 @@ |
||
| 53 | 53 | $this->from = $from; |
| 54 | 54 | $this->to = $to; |
| 55 | 55 | |
| 56 | - if(!is_null($this->from) && !is_null($this->to) && $this->from > $this->to) |
|
| 57 | - throw new \InvalidArgumentException("from should be lower than to param"); |
|
| 56 | + if(!is_null($this->from) && !is_null($this->to) && $this->from > $this->to) { |
|
| 57 | + throw new \InvalidArgumentException("from should be lower than to param"); |
|
| 58 | + } |
|
| 58 | 59 | } |
| 59 | 60 | |
| 60 | 61 | /** |