@@ -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()); |
@@ -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; |
@@ -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) { |
@@ -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(); |
@@ -51,7 +51,7 @@ |
||
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 |
@@ -53,7 +53,7 @@ |
||
53 | 53 | 'sources' => array_values(array_filter(array_unique($cfp->getSource()))), |
54 | 54 | 'lastChange' => $cfp->getLastUdated()->format('c'), |
55 | 55 | '_rel' => [ |
56 | - 'cfp_uri' => 'v1/cfp/' . $cfp->getHash(), |
|
56 | + 'cfp_uri' => 'v1/cfp/'.$cfp->getHash(), |
|
57 | 57 | ] |
58 | 58 | ]; |
59 | 59 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | \Psr\Http\Message\ResponseInterface $response |
44 | 44 | ) use ($app){ |
45 | 45 | $params = $request->getParsedBody(); |
46 | - if (! is_array($params)) { |
|
46 | + if (!is_array($params)) { |
|
47 | 47 | throw new UnexpectedValueException('Expected array'); |
48 | 48 | } |
49 | 49 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | try { |
52 | 52 | $cfp = $cfpFactory->createCfp($params, $app->getContainer()['client']); |
53 | 53 | } catch (\Exception $e) { |
54 | - error_log($e->getMessage() . "\n" . $e->getTraceAsString()); |
|
54 | + error_log($e->getMessage()."\n".$e->getTraceAsString()); |
|
55 | 55 | } |
56 | 56 | $cpl = new \Callingallpapers\Api\PersistenceLayer\CfpPersistenceLayer( |
57 | 57 | $app->getContainer()['pdo'], |
@@ -60,18 +60,18 @@ discard block |
||
60 | 60 | $cpl->insert($cfp); |
61 | 61 | |
62 | 62 | $uri = $request->getUri(); |
63 | - $uri = $uri->withPath('v1/cfp/' . $cfp->getId()); |
|
63 | + $uri = $uri->withPath('v1/cfp/'.$cfp->getId()); |
|
64 | 64 | return $response->withRedirect((string)$uri, 201); |
65 | 65 | }); |
66 | 66 | |
67 | 67 | |
68 | -$app->put('/v1/cfp/{hash}', function ( |
|
68 | +$app->put('/v1/cfp/{hash}', function( |
|
69 | 69 | \Psr\Http\Message\ServerRequestInterface $request, |
70 | 70 | \Psr\Http\Message\ResponseInterface $response, |
71 | 71 | array $args |
72 | 72 | ) use ($app){ |
73 | 73 | $params = $request->getParsedBody(); |
74 | - if (! is_array($params)) { |
|
74 | + if (!is_array($params)) { |
|
75 | 75 | throw new UnexpectedValueException('Expected array'); |
76 | 76 | } |
77 | 77 | |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | $cpl->update($cfp, $args['hash']); |
86 | 86 | |
87 | 87 | $uri = $request->getUri(); |
88 | - $uri = $uri->withPath('v1/cfp/' . $cfp->getId()); |
|
88 | + $uri = $uri->withPath('v1/cfp/'.$cfp->getId()); |
|
89 | 89 | return $response->withHeader('Location', (string)$uri)->withStatus(204); |
90 | 90 | }); |
91 | 91 | |
92 | 92 | |
93 | -$app->delete('/v1/cfp/{id}', function ( |
|
93 | +$app->delete('/v1/cfp/{id}', function( |
|
94 | 94 | \Psr\Http\Message\ServerRequestInterface $request, |
95 | 95 | \Psr\Http\Message\ResponseInterface $response |
96 | 96 | ) use ($app){ |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | return $response->withHeader('Content-Length', '0')->withStatus(204); |
105 | 105 | }); |
106 | 106 | |
107 | -$app->get('/v1/search', function ( |
|
107 | +$app->get('/v1/search', function( |
|
108 | 108 | \Psr\Http\Message\ServerRequestInterface $request, |
109 | 109 | \Psr\Http\Message\ResponseInterface $response, |
110 | 110 | array $args |
@@ -119,5 +119,5 @@ discard block |
||
119 | 119 | |
120 | 120 | $cfpMapper = new \Callingallpapers\Api\Entity\CfpListMapper(); |
121 | 121 | |
122 | - return $this->view->render($response, $cfpMapper->map($list), 200, 'cfp/list.twig');; |
|
122 | + return $this->view->render($response, $cfpMapper->map($list), 200, 'cfp/list.twig'); ; |
|
123 | 123 | }); |
@@ -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,15 +201,15 @@ 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 = filter_var( |
|
212 | + $latitude = filter_var( |
|
213 | 213 | $array['latitude'], |
214 | 214 | FILTER_SANITIZE_NUMBER_FLOAT, |
215 | 215 | 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 |