Completed
Pull Request — master (#18)
by Andreas
01:54
created
src/Middleware/ConvertTypeToAccept.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
         callable $next
52 52
     ) {
53 53
         $query = $request->getQueryParams();
54
-        if (! isset($query['type'])) {
54
+        if (!isset($query['type'])) {
55 55
             return $next($request, $response);
56 56
         }
57 57
 
Please login to merge, or discard this patch.
config/routes.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     \Psr\Http\Message\ResponseInterface $response
42 42
 ) use ($app){
43 43
     $params = $request->getParsedBody();
44
-    if (! is_array($params)) {
44
+    if (!is_array($params)) {
45 45
         throw new UnexpectedValueException('Expected array');
46 46
     }
47 47
 
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
     $cpl->insert($cfp);
55 55
 
56 56
     $uri = $request->getUri();
57
-    $uri = $uri->withPath('v1/cfp/' . $cfp->getId());
57
+    $uri = $uri->withPath('v1/cfp/'.$cfp->getId());
58 58
     return $response->withRedirect((string)$uri, 201);
59 59
 });
60 60
 
61 61
 
62
-$app->put('/v1/cfp/{hash}', function (
62
+$app->put('/v1/cfp/{hash}', function(
63 63
     \Psr\Http\Message\ServerRequestInterface $request,
64 64
     \Psr\Http\Message\ResponseInterface $response,
65 65
     array $args
66 66
 ) use ($app){
67 67
     $params = $request->getParsedBody();
68
-    if (! is_array($params)) {
68
+    if (!is_array($params)) {
69 69
         throw new UnexpectedValueException('Expected array');
70 70
     }
71 71
 
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
     $cpl->update($cfp, $args['hash']);
79 79
 
80 80
     $uri = $request->getUri();
81
-    $uri = $uri->withPath('v1/cfp/' . $cfp->getId());
81
+    $uri = $uri->withPath('v1/cfp/'.$cfp->getId());
82 82
     return $response->withHeader('Location', (string)$uri)->withStatus(204);
83 83
 });
84 84
 
85 85
 
86
-$app->delete('/v1/cfp/{id}', function (
86
+$app->delete('/v1/cfp/{id}', function(
87 87
     \Psr\Http\Message\ServerRequestInterface $request,
88 88
     \Psr\Http\Message\ResponseInterface $response
89 89
 ) use ($app){
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     return $response->withHeader('Content-Length', '0')->withStatus(204);
97 97
 });
98 98
 
99
-$app->get('/v1/search', function (
99
+$app->get('/v1/search', function(
100 100
     \Psr\Http\Message\ServerRequestInterface $request,
101 101
     \Psr\Http\Message\ResponseInterface $response,
102 102
     array $args
@@ -110,5 +110,5 @@  discard block
 block discarded – undo
110 110
 
111 111
     $cfpMapper = new \Callingallpapers\Api\Entity\CfpListMapper();
112 112
 
113
-    return $this->view->render($response, $cfpMapper->map($list), 200, 'cfp/list.twig');;
113
+    return $this->view->render($response, $cfpMapper->map($list), 200, 'cfp/list.twig'); ;
114 114
 });
Please login to merge, or discard this patch.
src/PersistenceLayer/CfpPersistenceLayer.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
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`, `lastUpdate`) ' .
73
+        $statement = 'INSERT into `cfp`(`dateCfpStart`, `dateCfpEnd`, `dateEventStart`, `dateEventEnd`, `name`, `uri`, `hash`, `timezone`, `description`, `eventUri`, `iconUri`, `latitude`, `longitude`, `location`, `tags`, `lastUpdate`) '.
74 74
                      'VALUES (:dateCfpStart, :dateCfpEnd, :dateEventStart, :dateEventEnd, :name, :uri, :hash, :timezone, :description, :eventUri, :iconUri, :latitude, :longitude, :location, :tags, :lastUpdate);';
75 75
         $statement = $this->pdo->prepare($statement);
76 76
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
     public function update(Cfp $cfp, $fetchHash)
104 104
     {
105
-        if (! $fetchHash) {
105
+        if (!$fetchHash) {
106 106
             throw new \UnexpectedValueException('No Hash given', 400);
107 107
         }
108 108
         $oldValues = $this->select($fetchHash);
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
         ];
133 133
 
134 134
         foreach ($options as $option) {
135
-            $method = 'get' . $option;
135
+            $method = 'get'.$option;
136 136
            // Merge values from tags and source before comparing!
137 137
             if (in_array($option, ['tags', 'source'])) {
138
-                $setter = 'set' . $option;
138
+                $setter = 'set'.$option;
139 139
                 $cfp->$setter(array_merge($oldValues->$method(), $cfp->$method()));
140 140
             }
141 141
             if ($cfp->$method() !== $oldValues->$method()) {
142 142
                 if ($option == 'dateCfpStart' && $cfp->$method()->getTimestamp() < 100000) {
143 143
                     continue;
144 144
                 }
145
-                $statementElements[] = '`' . $option . '` = :' . $option;
145
+                $statementElements[] = '`'.$option.'` = :'.$option;
146 146
                 $values[$option]     = $cfp->$method();
147 147
                 if ($values[$option] instanceof \DateTimeInterface) {
148 148
                     $values[$option] = $values[$option]->format('c');
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         }
163 163
 
164 164
         $statement = 'UPDATE `cfp` SET '
165
-                   . implode(',', $statementElements) . ','
165
+                   . implode(',', $statementElements).','
166 166
                    . '`lastUpdate` = :lastUpdate '
167 167
                    . 'WHERE `hash` = :fetchHash';
168 168
         $statement = $this->pdo->prepare($statement);
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
         $values    = [];
299 299
         $where = [];
300 300
         foreach ($parameters as $key => $value) {
301
-            if (! in_array($key, $fields)) {
301
+            if (!in_array($key, $fields)) {
302 302
                 continue;
303 303
             }
304
-            if (! is_array($value)) {
304
+            if (!is_array($value)) {
305 305
                 $value = [$value];
306 306
             }
307 307
             foreach ($value as $itemkey => $item) {
@@ -312,22 +312,22 @@  discard block
 block discarded – undo
312 312
                     'date_event_end',
313 313
                     'date_event_start'
314 314
                 ])) {
315
-                    if (array_key_exists($key . '_compare', $parameters) && isset($parameters[$key . '_compare'][$itemkey]) && in_array($parameters[$key . '_compare'][$itemkey], ['=', '<', '>', '<>'])) {
316
-                        $compare = $parameters[$key . '_compare'][$itemkey];
315
+                    if (array_key_exists($key.'_compare', $parameters) && isset($parameters[$key.'_compare'][$itemkey]) && in_array($parameters[$key.'_compare'][$itemkey], ['=', '<', '>', '<>'])) {
316
+                        $compare = $parameters[$key.'_compare'][$itemkey];
317 317
                     }
318
-                    $where[] = $this->timezoneHelper->getUtcDateTime($transformer->transform($key)) . ' ' . $compare . ' :' . $key . '_' . $itemkey;
318
+                    $where[] = $this->timezoneHelper->getUtcDateTime($transformer->transform($key)).' '.$compare.' :'.$key.'_'.$itemkey;
319 319
                     $value = (new DateTime($item))->setTimezone(new \DateTimeZone('UTC'))->format('c');
320 320
                 } else {
321
-                    $where[] = '`' . $transformer->transform($key) . '` ' . $compare . ' :' . $key;
321
+                    $where[] = '`'.$transformer->transform($key).'` '.$compare.' :'.$key;
322 322
                 }
323
-                $values[$key . '_' . $itemkey] = $value;
323
+                $values[$key.'_'.$itemkey] = $value;
324 324
             }
325 325
         }
326
-        if (! $where) {
326
+        if (!$where) {
327 327
             throw new \UnexpectedValueException('No CFPs found', 404);
328 328
         }
329 329
 
330
-        $statement .= implode(' AND ', $where) . ' ORDER BY dateCfpEnd ASC';
330
+        $statement .= implode(' AND ', $where).' ORDER BY dateCfpEnd ASC';
331 331
 
332 332
         $statement = $this->pdo->prepare($statement);
333 333
 
Please login to merge, or discard this patch.