Completed
Pull Request — master (#26)
by Andreas
02:45
created
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.
src/Service/CfpFactory.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         $cfp->setTimezone(filter_var($array['timezone'], FILTER_SANITIZE_STRING));
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
     public static function setUri(Cfp $cfp, array $array)
118 118
     {
119
-        if (! isset($array['uri'])) {
119
+        if (!isset($array['uri'])) {
120 120
             throw new \InvalidArgumentException('URI has to be specified');
121 121
         }
122 122
 
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
 
126 126
     public static function setEventUri(Cfp $cfp, array $array, Client $client)
127 127
     {
128
-        if (! isset($array['eventUri'])) {
128
+        if (!isset($array['eventUri'])) {
129 129
             throw new \InvalidArgumentException('Event-URI has to be specified');
130 130
         }
131 131
 
132 132
         try {
133 133
             $uri = '';
134 134
             $client->get($array['eventUri'], [
135
-                'on_stats' => function (TransferStats $stats) use (&$uri) {
135
+                'on_stats' => function(TransferStats $stats) use (&$uri) {
136 136
                     $uri = $stats->getEffectiveUri();
137 137
                 }
138 138
             ]);
139 139
         } catch (\Exception $e) {
140
-            throw new \InvalidArgumentException('Event-URI could not be verified: ' . $e->getMessage());
140
+            throw new \InvalidArgumentException('Event-URI could not be verified: '.$e->getMessage());
141 141
         }
142 142
 
143 143
         $cfp->setEventUri(filter_var($uri, FILTER_VALIDATE_URL));
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 
164 164
     public static function setIconUri(Cfp $cfp, array $array)
165 165
     {
166
-        if (! isset($array['iconUri'])) {
166
+        if (!isset($array['iconUri'])) {
167 167
             return;
168 168
         }
169 169
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
     public static function setDescription(Cfp $cfp, array $array)
174 174
     {
175
-        if (! isset($array['description'])) {
175
+        if (!isset($array['description'])) {
176 176
             return;
177 177
         }
178 178
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
     public static function setLocation(Cfp $cfp, array $array)
183 183
     {
184
-        if (! isset($array['location'])) {
184
+        if (!isset($array['location'])) {
185 185
             return;
186 186
         }
187 187
 
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 
191 191
     public static function setGeolocation(Cfp $cfp, array $array)
192 192
     {
193
-        if (! isset($array['latitude'])) {
193
+        if (!isset($array['latitude'])) {
194 194
             return;
195 195
         }
196 196
 
197
-        if (! isset($array['longitude'])) {
197
+        if (!isset($array['longitude'])) {
198 198
             return;
199 199
         }
200 200
 
201
-        $latitude  = filter_var(
201
+        $latitude = filter_var(
202 202
             $array['latitude'],
203 203
             FILTER_SANITIZE_NUMBER_FLOAT,
204 204
             FILTER_FLAG_ALLOW_FRACTION
@@ -231,18 +231,18 @@  discard block
 block discarded – undo
231 231
 
232 232
     public static function setTags(Cfp $cfp, array $array)
233 233
     {
234
-        if (! isset($array['tags'])) {
234
+        if (!isset($array['tags'])) {
235 235
             return;
236 236
         }
237 237
 
238
-        $cfp->setTags(array_map(function ($item) {
238
+        $cfp->setTags(array_map(function($item) {
239 239
             return filter_var($item, FILTER_SANITIZE_STRING);
240 240
         }, $array['tags']));
241 241
     }
242 242
 
243 243
     public static function setSource(Cfp $cfp, array $array)
244 244
     {
245
-        if (! isset($array['source'])) {
245
+        if (!isset($array['source'])) {
246 246
             return;
247 247
         }
248 248
 
Please login to merge, or discard this patch.