@@ -28,7 +28,6 @@ |
||
28 | 28 | namespace Callingallpapers\Api\PersistenceLayer; |
29 | 29 | |
30 | 30 | use Callingallpapers\Api\Entity\Cfp; |
31 | -use Monolog\Logger; |
|
32 | 31 | |
33 | 32 | class CfpPersistenceLayer |
34 | 33 | { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $cfp->setDateCfpStart(new \DateTimeImmutable()); |
68 | 68 | } |
69 | 69 | $statement = 'INSERT into `cfp`(`dateCfpStart`, `dateCfpEnd`, `dateEventStart`, `dateEventEnd`, `name`, `uri`, `hash`, `timezone`, `description`, `eventUri`, `iconUri`, `latitude`, `longitude`, `location`, `tags`, `lastUpdate`) ' . |
70 | - 'VALUES (:dateCfpStart, :dateCfpEnd, :dateEventStart, :dateEventEnd, :name, :uri, :hash, :timezone, :description, :eventUri, :iconUri, :latitude, :longitude, :location, :tags, :lastUpdate);'; |
|
70 | + 'VALUES (:dateCfpStart, :dateCfpEnd, :dateEventStart, :dateEventEnd, :name, :uri, :hash, :timezone, :description, :eventUri, :iconUri, :latitude, :longitude, :location, :tags, :lastUpdate);'; |
|
71 | 71 | $statement = $this->pdo->prepare($statement); |
72 | 72 | |
73 | 73 | $values = [ |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | foreach ($options as $option) { |
131 | 131 | $method = 'get' . $option; |
132 | - // Merge values from tags and source before comparing! |
|
132 | + // Merge values from tags and source before comparing! |
|
133 | 133 | if (in_array($option, ['tags', 'source'])) { |
134 | 134 | $setter = 'set' . $option; |
135 | 135 | $cfp->$setter(array_merge($oldValues->$method(), $cfp->$method())); |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | $statement = 'UPDATE `cfp` SET ' |
161 | - . implode(',', $statementElements) . ',' |
|
162 | - . '`lastUpdate` = :lastUpdate ' |
|
163 | - . 'WHERE `hash` = :fetchHash'; |
|
161 | + . implode(',', $statementElements) . ',' |
|
162 | + . '`lastUpdate` = :lastUpdate ' |
|
163 | + . 'WHERE `hash` = :fetchHash'; |
|
164 | 164 | $statement = $this->pdo->prepare($statement); |
165 | 165 | $values['fetchHash'] = $fetchHash; |
166 | 166 | $values['lastUpdate'] = (new \DateTime('now', new \DateTimezone('UTC')))->format('c'); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $cfp->setLocation($item['location']); |
354 | 354 | $cfp->setTags(explode(',', $item['tags'])); |
355 | 355 | $cfp->setLastUpdated(new \DateTimeImmutable($item['lastUpdate'])); |
356 | - // $cfp->setSource(explode(',', $item['source'])); |
|
356 | + // $cfp->setSource(explode(',', $item['source'])); |
|
357 | 357 | |
358 | 358 | $list->add($cfp); |
359 | 359 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | if ($cfp->getDateCfpStart()->getTimestamp() < 10000) { |
67 | 67 | $cfp->setDateCfpStart(new \DateTimeImmutable()); |
68 | 68 | } |
69 | - $statement = 'INSERT into `cfp`(`dateCfpStart`, `dateCfpEnd`, `dateEventStart`, `dateEventEnd`, `name`, `uri`, `hash`, `timezone`, `description`, `eventUri`, `iconUri`, `latitude`, `longitude`, `location`, `tags`, `lastUpdate`) ' . |
|
69 | + $statement = 'INSERT into `cfp`(`dateCfpStart`, `dateCfpEnd`, `dateEventStart`, `dateEventEnd`, `name`, `uri`, `hash`, `timezone`, `description`, `eventUri`, `iconUri`, `latitude`, `longitude`, `location`, `tags`, `lastUpdate`) '. |
|
70 | 70 | 'VALUES (:dateCfpStart, :dateCfpEnd, :dateEventStart, :dateEventEnd, :name, :uri, :hash, :timezone, :description, :eventUri, :iconUri, :latitude, :longitude, :location, :tags, :lastUpdate);'; |
71 | 71 | $statement = $this->pdo->prepare($statement); |
72 | 72 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | public function update(Cfp $cfp, $fetchHash) |
100 | 100 | { |
101 | - if (! $fetchHash) { |
|
101 | + if (!$fetchHash) { |
|
102 | 102 | throw new \UnexpectedValueException('No Hash given', 400); |
103 | 103 | } |
104 | 104 | $oldValues = $this->select($fetchHash); |
@@ -128,17 +128,17 @@ discard block |
||
128 | 128 | ]; |
129 | 129 | |
130 | 130 | foreach ($options as $option) { |
131 | - $method = 'get' . $option; |
|
131 | + $method = 'get'.$option; |
|
132 | 132 | // Merge values from tags and source before comparing! |
133 | 133 | if (in_array($option, ['tags', 'source'])) { |
134 | - $setter = 'set' . $option; |
|
134 | + $setter = 'set'.$option; |
|
135 | 135 | $cfp->$setter(array_merge($oldValues->$method(), $cfp->$method())); |
136 | 136 | } |
137 | 137 | if ($cfp->$method() !== $oldValues->$method()) { |
138 | 138 | if ($option == 'dateCfpStart' && $cfp->$method()->getTimestamp() < 100000) { |
139 | 139 | continue; |
140 | 140 | } |
141 | - $statementElements[] = '`' . $option . '` = :' . $option; |
|
141 | + $statementElements[] = '`'.$option.'` = :'.$option; |
|
142 | 142 | $values[$option] = $cfp->$method(); |
143 | 143 | if ($values[$option] instanceof \DateTimeInterface) { |
144 | 144 | $values[$option] = $values[$option]->format('c'); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | $statement = 'UPDATE `cfp` SET ' |
161 | - . implode(',', $statementElements) . ',' |
|
161 | + . implode(',', $statementElements).',' |
|
162 | 162 | . '`lastUpdate` = :lastUpdate ' |
163 | 163 | . 'WHERE `hash` = :fetchHash'; |
164 | 164 | $statement = $this->pdo->prepare($statement); |
@@ -294,13 +294,13 @@ discard block |
||
294 | 294 | $values = []; |
295 | 295 | $where = []; |
296 | 296 | foreach ($parameters as $key => $value) { |
297 | - if (! in_array($key, $fields)) { |
|
297 | + if (!in_array($key, $fields)) { |
|
298 | 298 | continue; |
299 | 299 | } |
300 | - if (! is_array($value)){ |
|
300 | + if (!is_array($value)) { |
|
301 | 301 | $value = [$value]; |
302 | 302 | } |
303 | - foreach($value as $itemkey => $item) { |
|
303 | + foreach ($value as $itemkey => $item) { |
|
304 | 304 | $compare = '='; |
305 | 305 | if (in_array($key, [ |
306 | 306 | 'date_cfp_end', |
@@ -308,19 +308,19 @@ discard block |
||
308 | 308 | 'date_event_end', |
309 | 309 | 'date_event_start' |
310 | 310 | ])) { |
311 | - if (array_key_exists($key . '_compare', $parameters) && isset($parameters[$key . '_compare'][$itemkey]) && in_array($parameters[$key . '_compare'][$itemkey], ['=', '<', '>', '<>'])) { |
|
312 | - $compare = $parameters[$key . '_compare'][$itemkey]; |
|
311 | + if (array_key_exists($key.'_compare', $parameters) && isset($parameters[$key.'_compare'][$itemkey]) && in_array($parameters[$key.'_compare'][$itemkey], ['=', '<', '>', '<>'])) { |
|
312 | + $compare = $parameters[$key.'_compare'][$itemkey]; |
|
313 | 313 | } |
314 | - $where[] = 'datetime(`' . $transformer->transform($key) . '`) ' . $compare . ' datetime(:' . $key . '_' . $itemkey . ')'; |
|
314 | + $where[] = 'datetime(`'.$transformer->transform($key).'`) '.$compare.' datetime(:'.$key.'_'.$itemkey.')'; |
|
315 | 315 | // $where[] = '`' . $transformer->transform($key) . '` ' . $compare . ' CONVERT_TZ(:' . $key . ', timezone, \'UTC\')'; |
316 | 316 | $value = (new DateTime($item))->setTimezone(new \DateTimeZone('UTC'))->format('c'); |
317 | 317 | } else { |
318 | - $where[] = '`' . $transformer->transform($key) . '` ' . $compare . ' :' . $key; |
|
318 | + $where[] = '`'.$transformer->transform($key).'` '.$compare.' :'.$key; |
|
319 | 319 | } |
320 | - $values[$key . '_' . $itemkey] = $value; |
|
320 | + $values[$key.'_'.$itemkey] = $value; |
|
321 | 321 | } |
322 | 322 | } |
323 | - if (! $where) { |
|
323 | + if (!$where) { |
|
324 | 324 | throw new \UnexpectedValueException('No CFPs found', 404); |
325 | 325 | } |
326 | 326 |
@@ -4,13 +4,13 @@ |
||
4 | 4 | $container = $app->getContainer(); |
5 | 5 | |
6 | 6 | // view renderer |
7 | -$container['renderer'] = function ($c) { |
|
7 | +$container['renderer'] = function($c) { |
|
8 | 8 | $settings = $c->get('settings')['renderer']; |
9 | 9 | return new Slim\Views\PhpRenderer($settings['template_path']); |
10 | 10 | }; |
11 | 11 | |
12 | 12 | // monolog |
13 | -$container['logger'] = function ($c) { |
|
13 | +$container['logger'] = function($c) { |
|
14 | 14 | $settings = $c->get('settings')['logger']; |
15 | 15 | $logger = new Monolog\Logger($settings['name']); |
16 | 16 | $logger->pushProcessor(new Monolog\Processor\UidProcessor()); |
@@ -52,7 +52,7 @@ |
||
52 | 52 | 'tags' => $cfp->getTags(), |
53 | 53 | 'lastChange' => $cfp->getLastUdated()->format('c'), |
54 | 54 | '_rel' => [ |
55 | - 'cfp_uri' => 'v1/cfp/' . $cfp->getHash(), |
|
55 | + 'cfp_uri' => 'v1/cfp/'.$cfp->getHash(), |
|
56 | 56 | ] |
57 | 57 | ]; |
58 | 58 |
@@ -33,7 +33,7 @@ |
||
33 | 33 | |
34 | 34 | public function add(Cfp $cfp) |
35 | 35 | { |
36 | - if (! $this->has($cfp)) { |
|
36 | + if (!$this->has($cfp)) { |
|
37 | 37 | $this->cfps[] = $cfp; |
38 | 38 | } |
39 | 39 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | $bearer = explode(' ', $auth[0]); |
71 | - if (! isset($bearer[1])) { |
|
71 | + if (!isset($bearer[1])) { |
|
72 | 72 | return $this->getNoAuthResponse($response); |
73 | 73 | } |
74 | 74 | $bearer = $bearer[1]; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | protected function getNoAuthResponse($response, $error = 'no token', $description = 'No Access-Token provided') |
89 | 89 | { |
90 | - $response = $response->withHeader('WWW-Authenticate', 'Bearer realm="callingallpapers", error="' . $error . '", error_desciption="' . $description . '"'); |
|
90 | + $response = $response->withHeader('WWW-Authenticate', 'Bearer realm="callingallpapers", error="'.$error.'", error_desciption="'.$description.'"'); |
|
91 | 91 | $response = $response->withStatus(401); |
92 | 92 | |
93 | 93 | return $response; |
@@ -59,7 +59,7 @@ |
||
59 | 59 | |
60 | 60 | if (strpos($accept[0], 'text/html') !== false) { |
61 | 61 | $container = $this->app->getContainer(); |
62 | - $container['view'] = function ($container) { |
|
62 | + $container['view'] = function($container) { |
|
63 | 63 | $config = $container['settings']; |
64 | 64 | $tView = new \Slim\Views\Twig($config['renderer']['template_path'], |
65 | 65 | [ |
@@ -56,7 +56,7 @@ |
||
56 | 56 | 'uri' => 'http://andreas.heigl.org', |
57 | 57 | ]); |
58 | 58 | $feed->setDateModified(time()); |
59 | - if (! isset($data['cfps'])) { |
|
59 | + if (!isset($data['cfps'])) { |
|
60 | 60 | $data['cfps'] = []; |
61 | 61 | } |
62 | 62 | foreach ($data['cfps'] as $cfp) { |
@@ -36,7 +36,7 @@ |
||
36 | 36 | { |
37 | 37 | /** |
38 | 38 | * |
39 | - * @param Response $response |
|
39 | + * @param ResponseInterface $response |
|
40 | 40 | * @param array $data |
41 | 41 | * @param int $status |
42 | 42 | * |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function render(ResponseInterface $response, array $data = [], $status = 200) |
46 | 46 | { |
47 | 47 | $icalendar = new VCalendar(); |
48 | - if (! isset($data['cfps'])) { |
|
48 | + if (!isset($data['cfps'])) { |
|
49 | 49 | $data['cfps'] = []; |
50 | 50 | } |
51 | 51 | foreach ($data['cfps'] as $cfp) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | 'DTSTAMP' => $lastChange, |
67 | 67 | 'UID' => $cfp['_rel']['cfp_uri'], |
68 | 68 | 'DESCRIPTION' => $cfp['description'], |
69 | - 'GEO' => round($cfp['latitude'], 6) . ';' . round($cfp['longitude'], 6), |
|
69 | + 'GEO' => round($cfp['latitude'], 6).';'.round($cfp['longitude'], 6), |
|
70 | 70 | 'LOCATION' => $cfp['location'], |
71 | 71 | |
72 | 72 | ]); |
@@ -27,22 +27,22 @@ |
||
27 | 27 | * @since 15.01.2016 |
28 | 28 | * @link http://github.com/heiglandreas/callingallpapers |
29 | 29 | */ |
30 | -require_once realpath(__DIR__ . '/../vendor/autoload.php'); |
|
30 | +require_once realpath(__DIR__.'/../vendor/autoload.php'); |
|
31 | 31 | |
32 | 32 | session_start(); |
33 | 33 | |
34 | 34 | // Instantiate the app |
35 | -$settings = require __DIR__ . '/../config/settings.php'; |
|
35 | +$settings = require __DIR__.'/../config/settings.php'; |
|
36 | 36 | $app = new \Slim\App($settings); |
37 | 37 | |
38 | 38 | // Set up dependencies |
39 | -require __DIR__ . '/../config/dependencies.php'; |
|
39 | +require __DIR__.'/../config/dependencies.php'; |
|
40 | 40 | |
41 | 41 | // Register middleware |
42 | -require __DIR__ . '/../config/middleware.php'; |
|
42 | +require __DIR__.'/../config/middleware.php'; |
|
43 | 43 | |
44 | 44 | // Register routes |
45 | -require __DIR__ . '/../config/routes.php'; |
|
45 | +require __DIR__.'/../config/routes.php'; |
|
46 | 46 | |
47 | 47 | // Run app |
48 | 48 | $app->run(); |