@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | public function setTimezone($timezone) |
| 248 | 248 | { |
| 249 | - if (! $timezone instanceof \DateTimeZone) { |
|
| 249 | + if (!$timezone instanceof \DateTimeZone) { |
|
| 250 | 250 | $timezone = new \DateTimeZone($timezone); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | public function addSource($source) |
| 297 | 297 | { |
| 298 | - if (! in_array($source, $this->source)) { |
|
| 298 | + if (!in_array($source, $this->source)) { |
|
| 299 | 299 | $this->source[] = $source; |
| 300 | 300 | } |
| 301 | 301 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $cfp->setDateCfpStart(new \DateTimeImmutable()); |
| 72 | 72 | } |
| 73 | 73 | $statement = 'INSERT into `cfp`(`dateCfpStart`, `dateCfpEnd`, `dateEventStart`, `dateEventEnd`, `name`, `uri`, `hash`, `timezone`, `description`, `eventUri`, `iconUri`, `latitude`, `longitude`, `location`, `tags`, `source`, `lastUpdate`) ' . |
| 74 | - 'VALUES (:dateCfpStart, :dateCfpEnd, :dateEventStart, :dateEventEnd, :name, :uri, :hash, :timezone, :description, :eventUri, :iconUri, :latitude, :longitude, :location, :tags, :source, :lastUpdate);'; |
|
| 74 | + 'VALUES (:dateCfpStart, :dateCfpEnd, :dateEventStart, :dateEventEnd, :name, :uri, :hash, :timezone, :description, :eventUri, :iconUri, :latitude, :longitude, :location, :tags, :source, :lastUpdate);'; |
|
| 75 | 75 | $statement = $this->pdo->prepare($statement); |
| 76 | 76 | |
| 77 | 77 | $values = [ |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | foreach ($options as $option) { |
| 136 | 136 | $method = 'get' . $option; |
| 137 | - // Merge values from tags and source before comparing! |
|
| 137 | + // Merge values from tags and source before comparing! |
|
| 138 | 138 | if (in_array($option, ['tags', 'source'])) { |
| 139 | 139 | $setter = 'set' . $option; |
| 140 | 140 | $cfp->$setter(array_merge($oldValues->$method(), $cfp->$method())); |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $statement = 'UPDATE `cfp` SET ' |
| 166 | - . implode(',', $statementElements) . ',' |
|
| 167 | - . '`lastUpdate` = :lastUpdate ' |
|
| 168 | - . 'WHERE `hash` = :fetchHash'; |
|
| 166 | + . implode(',', $statementElements) . ',' |
|
| 167 | + . '`lastUpdate` = :lastUpdate ' |
|
| 168 | + . 'WHERE `hash` = :fetchHash'; |
|
| 169 | 169 | $statement = $this->pdo->prepare($statement); |
| 170 | 170 | $values['fetchHash'] = $fetchHash; |
| 171 | 171 | $values['lastUpdate'] = (new \DateTime('now', new \DateTimezone('UTC')))->format('c'); |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $cfp->setLocation($item['location']); |
| 357 | 357 | $cfp->setTags(explode(',', $item['tags'])); |
| 358 | 358 | $cfp->setLastUpdated(new \DateTimeImmutable($item['lastUpdate'])); |
| 359 | - // $cfp->setSource(explode(',', $item['source'])); |
|
| 359 | + // $cfp->setSource(explode(',', $item['source'])); |
|
| 360 | 360 | |
| 361 | 361 | $list->add($cfp); |
| 362 | 362 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | if ($cfp->getDateCfpStart()->getTimestamp() < 10000) { |
| 71 | 71 | $cfp->setDateCfpStart(new \DateTimeImmutable()); |
| 72 | 72 | } |
| 73 | - $statement = 'INSERT into `cfp`(`dateCfpStart`, `dateCfpEnd`, `dateEventStart`, `dateEventEnd`, `name`, `uri`, `hash`, `timezone`, `description`, `eventUri`, `iconUri`, `latitude`, `longitude`, `location`, `tags`, `source`, `lastUpdate`) ' . |
|
| 73 | + $statement = 'INSERT into `cfp`(`dateCfpStart`, `dateCfpEnd`, `dateEventStart`, `dateEventEnd`, `name`, `uri`, `hash`, `timezone`, `description`, `eventUri`, `iconUri`, `latitude`, `longitude`, `location`, `tags`, `source`, `lastUpdate`) '. |
|
| 74 | 74 | 'VALUES (:dateCfpStart, :dateCfpEnd, :dateEventStart, :dateEventEnd, :name, :uri, :hash, :timezone, :description, :eventUri, :iconUri, :latitude, :longitude, :location, :tags, :source, :lastUpdate);'; |
| 75 | 75 | $statement = $this->pdo->prepare($statement); |
| 76 | 76 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | public function update(Cfp $cfp, $fetchHash) |
| 105 | 105 | { |
| 106 | - if (! $fetchHash) { |
|
| 106 | + if (!$fetchHash) { |
|
| 107 | 107 | throw new \UnexpectedValueException('No Hash given', 400); |
| 108 | 108 | } |
| 109 | 109 | $oldValues = $this->select($fetchHash); |
@@ -133,17 +133,17 @@ discard block |
||
| 133 | 133 | ]; |
| 134 | 134 | |
| 135 | 135 | foreach ($options as $option) { |
| 136 | - $method = 'get' . $option; |
|
| 136 | + $method = 'get'.$option; |
|
| 137 | 137 | // Merge values from tags and source before comparing! |
| 138 | 138 | if (in_array($option, ['tags', 'source'])) { |
| 139 | - $setter = 'set' . $option; |
|
| 139 | + $setter = 'set'.$option; |
|
| 140 | 140 | $cfp->$setter(array_merge($oldValues->$method(), $cfp->$method())); |
| 141 | 141 | } |
| 142 | 142 | if ($cfp->$method() !== $oldValues->$method()) { |
| 143 | 143 | if ($option == 'dateCfpStart' && $cfp->$method()->getTimestamp() < 100000) { |
| 144 | 144 | continue; |
| 145 | 145 | } |
| 146 | - $statementElements[] = '`' . $option . '` = :' . $option; |
|
| 146 | + $statementElements[] = '`'.$option.'` = :'.$option; |
|
| 147 | 147 | $values[$option] = $cfp->$method(); |
| 148 | 148 | if ($values[$option] instanceof \DateTimeInterface) { |
| 149 | 149 | $values[$option] = $values[$option]->format('c'); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $statement = 'UPDATE `cfp` SET ' |
| 166 | - . implode(',', $statementElements) . ',' |
|
| 166 | + . implode(',', $statementElements).',' |
|
| 167 | 167 | . '`lastUpdate` = :lastUpdate ' |
| 168 | 168 | . 'WHERE `hash` = :fetchHash'; |
| 169 | 169 | $statement = $this->pdo->prepare($statement); |
@@ -299,10 +299,10 @@ discard block |
||
| 299 | 299 | $values = []; |
| 300 | 300 | $where = []; |
| 301 | 301 | foreach ($parameters as $key => $value) { |
| 302 | - if (! in_array($key, $fields)) { |
|
| 302 | + if (!in_array($key, $fields)) { |
|
| 303 | 303 | continue; |
| 304 | 304 | } |
| 305 | - if (! is_array($value)) { |
|
| 305 | + if (!is_array($value)) { |
|
| 306 | 306 | $value = [$value]; |
| 307 | 307 | } |
| 308 | 308 | foreach ($value as $itemkey => $item) { |
@@ -313,22 +313,22 @@ discard block |
||
| 313 | 313 | 'date_event_end', |
| 314 | 314 | 'date_event_start' |
| 315 | 315 | ])) { |
| 316 | - if (array_key_exists($key . '_compare', $parameters) && isset($parameters[$key . '_compare'][$itemkey]) && in_array($parameters[$key . '_compare'][$itemkey], ['=', '<', '>', '<>'])) { |
|
| 317 | - $compare = $parameters[$key . '_compare'][$itemkey]; |
|
| 316 | + if (array_key_exists($key.'_compare', $parameters) && isset($parameters[$key.'_compare'][$itemkey]) && in_array($parameters[$key.'_compare'][$itemkey], ['=', '<', '>', '<>'])) { |
|
| 317 | + $compare = $parameters[$key.'_compare'][$itemkey]; |
|
| 318 | 318 | } |
| 319 | - $where[] = $this->timezoneHelper->getUtcDateTime($transformer->transform($key)) . ' ' . $compare . ' :' . $key . '_' . $itemkey; |
|
| 319 | + $where[] = $this->timezoneHelper->getUtcDateTime($transformer->transform($key)).' '.$compare.' :'.$key.'_'.$itemkey; |
|
| 320 | 320 | $value = (new DateTime($item))->setTimezone(new \DateTimeZone('UTC'))->format('c'); |
| 321 | 321 | } else { |
| 322 | - $where[] = '`' . $transformer->transform($key) . '` ' . $compare . ' :' . $key; |
|
| 322 | + $where[] = '`'.$transformer->transform($key).'` '.$compare.' :'.$key; |
|
| 323 | 323 | } |
| 324 | - $values[$key . '_' . $itemkey] = $value; |
|
| 324 | + $values[$key.'_'.$itemkey] = $value; |
|
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | - if (! $where) { |
|
| 327 | + if (!$where) { |
|
| 328 | 328 | throw new \UnexpectedValueException('No CFPs found', 404); |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - $statement .= implode(' AND ', $where) . ' ORDER BY dateCfpEnd ASC'; |
|
| 331 | + $statement .= implode(' AND ', $where).' ORDER BY dateCfpEnd ASC'; |
|
| 332 | 332 | |
| 333 | 333 | $statement = $this->pdo->prepare($statement); |
| 334 | 334 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | public function render(ResponseInterface $response, array $data = [], int $status = 200): ResponseInterface |
| 38 | 38 | { |
| 39 | 39 | $icalendar = new VCalendar(); |
| 40 | - if (! isset($data['cfps'])) { |
|
| 40 | + if (!isset($data['cfps'])) { |
|
| 41 | 41 | $data['cfps'] = []; |
| 42 | 42 | } |
| 43 | 43 | foreach ($data['cfps'] as $cfp) { |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | 'DTSTAMP' => $lastChange, |
| 59 | 59 | 'UID' => $cfp['_rel']['cfp_uri'], |
| 60 | 60 | 'DESCRIPTION' => $cfp['description'], |
| 61 | - 'GEO' => round($cfp['latitude'], 6) . ';' . round($cfp['longitude'], 6), |
|
| 61 | + 'GEO' => round($cfp['latitude'], 6).';'.round($cfp['longitude'], 6), |
|
| 62 | 62 | 'LOCATION' => $cfp['location'], |
| 63 | 63 | |
| 64 | 64 | ]); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $missingFields = []; |
| 52 | 52 | |
| 53 | 53 | foreach ($requiredFields as $field) { |
| 54 | - if (! isset($params[$field])) { |
|
| 54 | + if (!isset($params[$field])) { |
|
| 55 | 55 | $missingFields[] = $field; |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | public static function setName(Cfp $cfp, array $array) |
| 86 | 86 | { |
| 87 | - if (! isset($array['name'])) { |
|
| 87 | + if (!isset($array['name'])) { |
|
| 88 | 88 | throw new \InvalidArgumentException('Name has to be specified'); |
| 89 | 89 | } |
| 90 | 90 | $cfp->setName(filter_var($array['name'], FILTER_SANITIZE_STRING)); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | public static function setDateCfpStart(Cfp $cfp, array $array) |
| 94 | 94 | { |
| 95 | - if (! isset($array['dateCfpStart'])) { |
|
| 95 | + if (!isset($array['dateCfpStart'])) { |
|
| 96 | 96 | $array['dateCfpStart'] = '@0'; |
| 97 | 97 | } |
| 98 | 98 | $cfp->setDateCfpStart(new DateTimeImmutable($array['dateCfpStart'])); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | public static function setDateCfpEnd(Cfp $cfp, array $array) |
| 102 | 102 | { |
| 103 | - if (! isset($array['dateCfpEnd'])) { |
|
| 103 | + if (!isset($array['dateCfpEnd'])) { |
|
| 104 | 104 | throw new \InvalidArgumentException('CFP-EndDate has to be specified'); |
| 105 | 105 | } |
| 106 | 106 | $cfp->setDateCfpEnd(new DateTimeImmutable($array['dateCfpEnd'])); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | public static function setTimezone(Cfp $cfp, array $array) |
| 110 | 110 | { |
| 111 | - if (! isset($array['timezone'])) { |
|
| 111 | + if (!isset($array['timezone'])) { |
|
| 112 | 112 | throw new \InvalidArgumentException('Timezone has to be specified'); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | public static function setUri(Cfp $cfp, array $array) |
| 123 | 123 | { |
| 124 | - if (! isset($array['uri'])) { |
|
| 124 | + if (!isset($array['uri'])) { |
|
| 125 | 125 | throw new \InvalidArgumentException('URI has to be specified'); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -130,22 +130,22 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | public static function setEventUri(Cfp $cfp, array $array, Client $client) |
| 132 | 132 | { |
| 133 | - if (! isset($array['eventUri'])) { |
|
| 133 | + if (!isset($array['eventUri'])) { |
|
| 134 | 134 | throw new \InvalidArgumentException('Event-URI has to be specified'); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | try { |
| 138 | 138 | $uri = ''; |
| 139 | 139 | $client->get($array['eventUri'], [ |
| 140 | - 'on_stats' => function (TransferStats $stats) use (&$uri) { |
|
| 140 | + 'on_stats' => function(TransferStats $stats) use (&$uri) { |
|
| 141 | 141 | $uri = $stats->getEffectiveUri(); |
| 142 | 142 | } |
| 143 | 143 | ]); |
| 144 | 144 | } catch (\Exception $e) { |
| 145 | - throw new \InvalidArgumentException('Event-URI could not be verified: ' . $e->getMessage()); |
|
| 145 | + throw new \InvalidArgumentException('Event-URI could not be verified: '.$e->getMessage()); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $uri = (string) $uri; |
|
| 148 | + $uri = (string)$uri; |
|
| 149 | 149 | $pos = strpos($uri, '?'); |
| 150 | 150 | if ($pos !== false) { |
| 151 | 151 | $uri = substr($uri, 0, $pos); |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | public static function setIconUri(Cfp $cfp, array $array) |
| 176 | 176 | { |
| 177 | - if (! isset($array['iconUri'])) { |
|
| 177 | + if (!isset($array['iconUri'])) { |
|
| 178 | 178 | return; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | public static function setDescription(Cfp $cfp, array $array) |
| 185 | 185 | { |
| 186 | - if (! isset($array['description'])) { |
|
| 186 | + if (!isset($array['description'])) { |
|
| 187 | 187 | return; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | public static function setLocation(Cfp $cfp, array $array) |
| 194 | 194 | { |
| 195 | - if (! isset($array['location'])) { |
|
| 195 | + if (!isset($array['location'])) { |
|
| 196 | 196 | return; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -201,20 +201,20 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | public static function setGeolocation(Cfp $cfp, array $array) |
| 203 | 203 | { |
| 204 | - if (! isset($array['latitude'])) { |
|
| 204 | + if (!isset($array['latitude'])) { |
|
| 205 | 205 | return; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if (! isset($array['longitude'])) { |
|
| 208 | + if (!isset($array['longitude'])) { |
|
| 209 | 209 | return; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - $latitude = (float) filter_var( |
|
| 212 | + $latitude = (float)filter_var( |
|
| 213 | 213 | $array['latitude'], |
| 214 | 214 | FILTER_SANITIZE_NUMBER_FLOAT, |
| 215 | 215 | FILTER_FLAG_ALLOW_FRACTION |
| 216 | 216 | ); |
| 217 | - $longitude = (float) filter_var( |
|
| 217 | + $longitude = (float)filter_var( |
|
| 218 | 218 | $array['longitude'], |
| 219 | 219 | FILTER_SANITIZE_NUMBER_FLOAT, |
| 220 | 220 | FILTER_FLAG_ALLOW_FRACTION |
@@ -242,18 +242,18 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | public static function setTags(Cfp $cfp, array $array) |
| 244 | 244 | { |
| 245 | - if (! isset($array['tags'])) { |
|
| 245 | + if (!isset($array['tags'])) { |
|
| 246 | 246 | return; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - $cfp->setTags(array_map(function ($item) { |
|
| 249 | + $cfp->setTags(array_map(function($item) { |
|
| 250 | 250 | return filter_var($item, FILTER_SANITIZE_STRING); |
| 251 | 251 | }, $array['tags'])); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | public static function setSource(Cfp $cfp, array $array) |
| 255 | 255 | { |
| 256 | - if (! isset($array['source'])) { |
|
| 256 | + if (!isset($array['source'])) { |
|
| 257 | 257 | return; |
| 258 | 258 | } |
| 259 | 259 | |