@@ -96,7 +96,7 @@ |
||
96 | 96 | try { |
97 | 97 | $responseContent = $this->adapter->call( |
98 | 98 | 'POST', |
99 | - $this->getUrl() . static::TOKEN_ENDPOINT, |
|
99 | + $this->getUrl().static::TOKEN_ENDPOINT, |
|
100 | 100 | array(), |
101 | 101 | $postFields |
102 | 102 | ); |
@@ -112,8 +112,8 @@ |
||
112 | 112 | { |
113 | 113 | $entity = new static::$mappings[$name]['entity'](); |
114 | 114 | |
115 | - array_walk($data, function ($value, $property) use ($entity) { |
|
116 | - $method = 'set'.implode('', array_map(function ($chunk) { |
|
115 | + array_walk($data, function($value, $property) use ($entity) { |
|
116 | + $method = 'set'.implode('', array_map(function($chunk) { |
|
117 | 117 | return ucfirst($chunk); |
118 | 118 | }, preg_split('/[-_]/', $property))); |
119 | 119 |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function getThumbnail() |
140 | 140 | { |
141 | - if (! isset($this->source->thumbnail)) { |
|
141 | + if (!isset($this->source->thumbnail)) { |
|
142 | 142 | return null; |
143 | 143 | } |
144 | 144 | |
@@ -191,8 +191,7 @@ discard block |
||
191 | 191 | public function getRecordCount() |
192 | 192 | { |
193 | 193 | return $this->recordCount !== null ? |
194 | - $this->recordCount : |
|
195 | - $this->recordCount = |
|
194 | + $this->recordCount : $this->recordCount = |
|
196 | 195 | (isset($this->source->record_count) ? $this->source->record_count : count($this->getRecords())); |
197 | 196 | } |
198 | 197 | |
@@ -201,7 +200,7 @@ discard block |
||
201 | 200 | */ |
202 | 201 | public function getRecords() |
203 | 202 | { |
204 | - if (! isset($this->source->records)) { |
|
203 | + if (!isset($this->source->records)) { |
|
205 | 204 | $this->records = new ArrayCollection(); |
206 | 205 | } |
207 | 206 | |
@@ -215,7 +214,7 @@ discard block |
||
215 | 214 | */ |
216 | 215 | public function getMetadata() |
217 | 216 | { |
218 | - if (! isset($this->source->metadata)) { |
|
217 | + if (!isset($this->source->metadata)) { |
|
219 | 218 | $this->metadata = new ArrayCollection(); |
220 | 219 | } |
221 | 220 | |
@@ -229,7 +228,7 @@ discard block |
||
229 | 228 | */ |
230 | 229 | public function getStatus() |
231 | 230 | { |
232 | - if (! isset($this->status)) { |
|
231 | + if (!isset($this->status)) { |
|
233 | 232 | $this->status = $this->entityManager->getRepository('recordStatus')->findByRecord( |
234 | 233 | $this->getDataboxId(), |
235 | 234 | $this->getStoryId() |
@@ -244,11 +243,11 @@ discard block |
||
244 | 243 | */ |
245 | 244 | public function getCaption() |
246 | 245 | { |
247 | - if (! isset($this->caption) && isset($this->source->caption)) { |
|
246 | + if (!isset($this->caption) && isset($this->source->caption)) { |
|
248 | 247 | $this->caption = RecordCaption::fromList((array) $this->source->caption); |
249 | 248 | } |
250 | 249 | |
251 | - if (! isset($this->caption)) { |
|
250 | + if (!isset($this->caption)) { |
|
252 | 251 | $this->caption = $this->entityManager->getRepository('caption')->findByRecord( |
253 | 252 | $this->getDataboxId(), |
254 | 253 | $this->getStoryId() |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | { |
22 | 22 | // 't' param is used for cache busting |
23 | 23 | $parameters = [ |
24 | - 'includes' => [ 'elements' ], |
|
24 | + 'includes' => ['elements'], |
|
25 | 25 | 't' => time() |
26 | 26 | ]; |
27 | 27 | |
28 | - $response = $this->query('GET', 'v2/orders/' . $orderId, $parameters); |
|
28 | + $response = $this->query('GET', 'v2/orders/'.$orderId, $parameters); |
|
29 | 29 | |
30 | 30 | if ($response->isEmpty()) { |
31 | 31 | throw new RuntimeException('Response content is empty'); |
32 | 32 | } |
33 | 33 | |
34 | - if (! $response->hasProperty('data')) { |
|
34 | + if (!$response->hasProperty('data')) { |
|
35 | 35 | throw new RuntimeException('Missing \'data\' property in response'); |
36 | 36 | } |
37 | 37 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $parameters = [ |
45 | 45 | 'page' => max($pageIndex, 0), |
46 | 46 | 'per_page' => max($pageSize, 1), |
47 | - 'includes' => [ 'elements' ], |
|
47 | + 'includes' => ['elements'], |
|
48 | 48 | 't' => time() |
49 | 49 | ]; |
50 | 50 | |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | throw new RuntimeException('Response content is empty'); |
55 | 55 | } |
56 | 56 | |
57 | - if (! $response->hasProperty('data')) { |
|
57 | + if (!$response->hasProperty('data')) { |
|
58 | 58 | throw new RuntimeException('Missing \'data\' property in response'); |
59 | 59 | } |
60 | 60 | |
61 | - if (! $response->hasProperty('meta')) { |
|
61 | + if (!$response->hasProperty('meta')) { |
|
62 | 62 | throw new RuntimeException('Missing \'meta\' property in response'); |
63 | 63 | } |
64 | 64 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | 'records' => $recordsIds |
75 | 75 | ]; |
76 | 76 | |
77 | - $response = $this->query('POST', 'v2/orders/', [], [ 'data' => $parameters ], [ |
|
77 | + $response = $this->query('POST', 'v2/orders/', [], ['data' => $parameters], [ |
|
78 | 78 | 'Accept' => 'application/json', |
79 | 79 | 'Content-Type' => 'application/json' |
80 | 80 | ]); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | public function getBaseUrl() |
83 | 83 | { |
84 | 84 | // return $this->guzzleClient->getBaseUrl(); // removed |
85 | - return $this->baseUri ; |
|
85 | + return $this->baseUri; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -156,29 +156,29 @@ discard block |
||
156 | 156 | ]; |
157 | 157 | |
158 | 158 | // files -- receiving files has no usage found in the code, so format of $files is unknown, so... not implmented |
159 | - if(count($files) > 0) { |
|
160 | - throw new \GuzzleHttp\Exception\InvalidArgumentException('request with "files" is not implemented' ); |
|
159 | + if (count($files) > 0) { |
|
160 | + throw new \GuzzleHttp\Exception\InvalidArgumentException('request with "files" is not implemented'); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // postFields |
164 | - if(count($postFields) > 0) { |
|
165 | - if($method !== 'POST') { |
|
164 | + if (count($postFields) > 0) { |
|
165 | + if ($method !== 'POST') { |
|
166 | 166 | throw new InvalidArgumentException('postFields are only allowed with "POST" method'); |
167 | 167 | } |
168 | - if(count($files) > 0) { |
|
168 | + if (count($files) > 0) { |
|
169 | 169 | // this will not happen while "files" is not implemented |
170 | - throw new \GuzzleHttp\Exception\InvalidArgumentException('request can\'t contain both postFields and files' ); |
|
170 | + throw new \GuzzleHttp\Exception\InvalidArgumentException('request can\'t contain both postFields and files'); |
|
171 | 171 | } |
172 | 172 | $options[RequestOptions::FORM_PARAMS] = $postFields; |
173 | 173 | } |
174 | 174 | |
175 | 175 | // headers |
176 | 176 | $h = array_merge($acceptHeader, $headers); |
177 | - if($this->userAgent !== '' && !array_key_exists('User-Agent', $h)) { |
|
177 | + if ($this->userAgent !== '' && !array_key_exists('User-Agent', $h)) { |
|
178 | 178 | // use the defaut user-agent if none is provided in headers |
179 | 179 | $h['User-Agent'] = sprintf('%s version %s', ApplicationInterface::USER_AGENT, ApplicationInterface::VERSION); |
180 | 180 | } |
181 | - if(count($h) > 0) { |
|
181 | + if (count($h) > 0) { |
|
182 | 182 | $options[RequestOptions::HEADERS] = $h; |
183 | 183 | } |
184 | 184 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | public function register(SilexApplication $app) |
26 | 26 | { |
27 | - $app['phraseanet-sdk.config'] = $app->share(function () use ($app) { |
|
27 | + $app['phraseanet-sdk.config'] = $app->share(function() use ($app) { |
|
28 | 28 | return array_replace( |
29 | 29 | array( |
30 | 30 | 'client-id' => null, |
@@ -35,26 +35,26 @@ discard block |
||
35 | 35 | ); |
36 | 36 | }); |
37 | 37 | |
38 | - $app['phraseanet-sdk.guzzle.plugins'] = $app->share(function ($app) { |
|
38 | + $app['phraseanet-sdk.guzzle.plugins'] = $app->share(function($app) { |
|
39 | 39 | return []; |
40 | 40 | }); |
41 | 41 | |
42 | - $app['phraseanet-sdk.guzzle-adapter'] = $app->share(function (SilexApplication $app) { |
|
42 | + $app['phraseanet-sdk.guzzle-adapter'] = $app->share(function(SilexApplication $app) { |
|
43 | 43 | return GuzzleAdapter::create( |
44 | 44 | $app['phraseanet-sdk.config']['url'], |
45 | 45 | $app['phraseanet-sdk.guzzle.plugins'] |
46 | 46 | ); |
47 | 47 | }); |
48 | 48 | |
49 | - $app['phraseanet-sdk.guzzle-connected-adapter'] = $app->protect(function ($token) use ($app) { |
|
49 | + $app['phraseanet-sdk.guzzle-connected-adapter'] = $app->protect(function($token) use ($app) { |
|
50 | 50 | return new ConnectedGuzzleAdapter($token, $app['phraseanet-sdk.guzzle-adapter']); |
51 | 51 | }); |
52 | 52 | |
53 | - $app['phraseanet-sdk.guzzle-api-adapter'] = $app->protect(function ($token) use ($app) { |
|
53 | + $app['phraseanet-sdk.guzzle-api-adapter'] = $app->protect(function($token) use ($app) { |
|
54 | 54 | return new APIGuzzleAdapter($app['phraseanet-sdk.guzzle-connected-adapter']($token)); |
55 | 55 | }); |
56 | 56 | |
57 | - $app['phraseanet-sdk'] = $app->share(function (SilexApplication $app) { |
|
57 | + $app['phraseanet-sdk'] = $app->share(function(SilexApplication $app) { |
|
58 | 58 | return Application::create($app['phraseanet-sdk.config'], $app['phraseanet-sdk.guzzle-adapter']); |
59 | 59 | }); |
60 | 60 | } |