@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public function handle(string $action, array $payload, bool $isPreview) |
| 36 | 36 | { |
| 37 | 37 | $actionMethods = ['create', 'archive', 'unarchive', 'publish', 'unpublish', 'delete']; |
| 38 | - $actionMethods = ! empty($isPreview) ? array_merge($actionMethods, ['save', 'auto_save']): $actionMethods; |
|
| 38 | + $actionMethods = !empty($isPreview) ? array_merge($actionMethods, ['save', 'auto_save']) : $actionMethods; |
|
| 39 | 39 | |
| 40 | 40 | if (method_exists($this, $action) && in_array($action, $actionMethods)) { |
| 41 | 41 | $this->$action($payload); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | $locales = Locale::all(); |
| 160 | 160 | $locales = is_array($locales) ? collect($locales) : $locales; |
| 161 | - $this->entries->toContentfulModel($payload,$locales); |
|
| 161 | + $this->entries->toContentfulModel($payload, $locales); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function handle(array $headers, array $payload, bool $isPreview = false): array |
| 18 | 18 | { |
| 19 | - if (! isset($headers['x-contentful-topic'])) { |
|
| 19 | + if (!isset($headers['x-contentful-topic'])) { |
|
| 20 | 20 | return $this->response('Page not found', 404); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $handler = null; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if (! empty($handler)) { |
|
| 40 | + if (!empty($handler)) { |
|
| 41 | 41 | try { |
| 42 | 42 | $handler->handle($topics[2], $payload, $isPreview); |
| 43 | 43 | } catch (Exception $e) { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | return [ |
| 61 | 61 | 'status' => $status, |
| 62 | - 'message' => ! empty($message) ? $message : null, |
|
| 62 | + 'message' => !empty($message) ? $message : null, |
|
| 63 | 63 | ]; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | try { |
| 55 | 55 | $this->cleanEntry($importEntry); |
| 56 | 56 | } catch (GuzzleException $e) { |
| 57 | - $this->error(PHP_EOL . $e->getMessage()); |
|
| 57 | + $this->error(PHP_EOL.$e->getMessage()); |
|
| 58 | 58 | } |
| 59 | 59 | $bar->advance(); |
| 60 | 60 | } |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | private function cleanEntry(stdClass $entry) |
| 75 | 75 | { |
| 76 | 76 | if ($entry->contentful_type === 'asset') { |
| 77 | - if (! empty($entry->published_at)) { |
|
| 77 | + if (!empty($entry->published_at)) { |
|
| 78 | 78 | $this->api->unpublishAsset($entry->contentful_id); |
| 79 | 79 | } |
| 80 | 80 | $this->api->deleteAsset($entry->contentful_id); |
| 81 | 81 | } else { |
| 82 | - if (! empty($entry->published_at)) { |
|
| 82 | + if (!empty($entry->published_at)) { |
|
| 83 | 83 | $this->api->unpublishEntry($entry->contentful_id); |
| 84 | 84 | } |
| 85 | 85 | $this->api->deleteEntry($entry->contentful_id); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | try { |
| 83 | 83 | $assets = $this->api->syncInitial('Asset'); |
| 84 | - while (! empty($assets)) { |
|
| 84 | + while (!empty($assets)) { |
|
| 85 | 85 | $this->saveAssets($assets); |
| 86 | 86 | $assets = $this->api->syncNext(); |
| 87 | 87 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | protected function saveAssets(array $assets) |
| 100 | 100 | { |
| 101 | - DB::transaction(function () use ($assets) { |
|
| 101 | + DB::transaction(function() use ($assets) { |
|
| 102 | 102 | foreach ($assets as $asset) { |
| 103 | 103 | DB::table('sync_entries')->insert([ |
| 104 | 104 | 'contentful_id' => $asset['sys']['id'], |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | try { |
| 120 | 120 | $entries = $this->api->syncInitial('Entry'); |
| 121 | - while (! empty($entries)) { |
|
| 121 | + while (!empty($entries)) { |
|
| 122 | 122 | $this->saveEntries($entries); |
| 123 | 123 | $entries = $this->api->syncNext(); |
| 124 | 124 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | protected function saveEntries(array $entries) |
| 137 | 137 | { |
| 138 | - DB::transaction(function () use ($entries) { |
|
| 138 | + DB::transaction(function() use ($entries) { |
|
| 139 | 139 | foreach ($entries as $entry) { |
| 140 | 140 | DB::table('sync_entries')->insert([ |
| 141 | 141 | 'contentful_id' => $entry['sys']['id'], |
@@ -51,9 +51,9 @@ |
||
| 51 | 51 | */ |
| 52 | 52 | protected function query(string $endpoint, array $parameters): ResponseInterface |
| 53 | 53 | { |
| 54 | - $token = ! empty($this->config['use_preview']) ? 'preview' : 'live'; |
|
| 54 | + $token = !empty($this->config['use_preview']) ? 'preview' : 'live'; |
|
| 55 | 55 | |
| 56 | - $url = isset($parameters['id']) ? $this->url($endpoint) . '/' . $parameters['id'] : $this->url($endpoint); |
|
| 56 | + $url = isset($parameters['id']) ? $this->url($endpoint).'/'.$parameters['id'] : $this->url($endpoint); |
|
| 57 | 57 | unset($parameters['id']); |
| 58 | 58 | |
| 59 | 59 | return $this->client->request('GET', $url, [ |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | private function keyCache(array $parameters): string |
| 42 | 42 | { |
| 43 | - return 'delivery_api_' . (config('contentful.use_preview') ? 'preview_' : '') . md5(json_encode($parameters)); |
|
| 43 | + return 'delivery_api_'.(config('contentful.use_preview') ? 'preview_' : '').md5(json_encode($parameters)); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -59,6 +59,6 @@ discard block |
||
| 59 | 59 | Cache::forever($keyCache, $data); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - return ! empty($data) ? $data : []; |
|
| 62 | + return !empty($data) ? $data : []; |
|
| 63 | 63 | } |
| 64 | 64 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | RequestOptions::BODY => file_get_contents($file), |
| 23 | 23 | RequestOptions::HEADERS => [ |
| 24 | 24 | 'Content-Type' => 'application/octet-stream', |
| 25 | - 'Authorization' => 'Bearer ' . $this->config['tokens']['management'], |
|
| 25 | + 'Authorization' => 'Bearer '.$this->config['tokens']['management'], |
|
| 26 | 26 | ], |
| 27 | 27 | ]); |
| 28 | 28 | |
@@ -90,10 +90,10 @@ |
||
| 90 | 90 | { |
| 91 | 91 | $this->syncToken = ''; |
| 92 | 92 | |
| 93 | - if (isset($response['nextPageUrl']) && ! empty($response['nextPageUrl'])) { |
|
| 93 | + if (isset($response['nextPageUrl']) && !empty($response['nextPageUrl'])) { |
|
| 94 | 94 | $data = parse_url($response['nextPageUrl']); |
| 95 | 95 | |
| 96 | - if (isset($data['query']) && ! empty($data['query'])) { |
|
| 96 | + if (isset($data['query']) && !empty($data['query'])) { |
|
| 97 | 97 | parse_str($data['query'], $params); |
| 98 | 98 | |
| 99 | 99 | if (isset($params['sync_token'])) { |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | return [ |
| 49 | - 'title' => ! empty($model->title) ? $model->title : null, |
|
| 50 | - 'description' => ! empty($model->description) ? $model->description : null, |
|
| 49 | + 'title' => !empty($model->title) ? $model->title : null, |
|
| 50 | + 'description' => !empty($model->description) ? $model->description : null, |
|
| 51 | 51 | 'url' => $url, |
| 52 | 52 | ]; |
| 53 | 53 | } |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function transformCollection(Collection $collection, array $parameters = []): Collection |
| 63 | 63 | { |
| 64 | - $collection->filter(function ($value) { |
|
| 65 | - return ! empty($value); |
|
| 64 | + $collection->filter(function($value) { |
|
| 65 | + return !empty($value); |
|
| 66 | 66 | }); |
| 67 | 67 | |
| 68 | 68 | if ($collection->isEmpty()) { |
| 69 | 69 | return collect(); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - return $collection->transform(function ($model) use ($parameters) { |
|
| 72 | + return $collection->transform(function($model) use ($parameters) { |
|
| 73 | 73 | return $this->transform($model, $parameters); |
| 74 | 74 | }); |
| 75 | 75 | } |