@@ -9,7 +9,7 @@ |
||
9 | 9 | */ |
10 | 10 | public function modelGetter() |
11 | 11 | { |
12 | - $stubPath = __DIR__ . '/stubs/string.stub'; |
|
12 | + $stubPath = __DIR__.'/stubs/string.stub'; |
|
13 | 13 | |
14 | 14 | return self::getStub($stubPath, [ |
15 | 15 | 'field_camel' => studly_case($this->id()), |
@@ -13,13 +13,13 @@ |
||
13 | 13 | { |
14 | 14 | switch ($this->field['linkType']) { |
15 | 15 | case 'Entry': |
16 | - $stubPath = __DIR__ . '/stubs/entry.stub'; |
|
16 | + $stubPath = __DIR__.'/stubs/entry.stub'; |
|
17 | 17 | break; |
18 | 18 | case 'Asset': |
19 | - $stubPath = __DIR__ . '/stubs/asset.stub'; |
|
19 | + $stubPath = __DIR__.'/stubs/asset.stub'; |
|
20 | 20 | break; |
21 | 21 | default: |
22 | - throw new Exception('Unknown Array items type "' . $this->field['linkType'] . '"'); |
|
22 | + throw new Exception('Unknown Array items type "'.$this->field['linkType'].'"'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | return self::getStub($stubPath, [ |
@@ -60,7 +60,7 @@ |
||
60 | 60 | $content = file_get_contents($stubPath); |
61 | 61 | |
62 | 62 | foreach ($replacements as $key => $value) { |
63 | - $content = str_replace('{{' . mb_strtoupper($key) . '}}', $value, $content); |
|
63 | + $content = str_replace('{{'.mb_strtoupper($key).'}}', $value, $content); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return $content; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | protected function tableName($id) |
38 | 38 | { |
39 | - return DB::getTablePrefix() . str_plural(snake_case($id)); |
|
39 | + return DB::getTablePrefix().str_plural(snake_case($id)); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $content = file_get_contents($stubPath); |
55 | 55 | foreach ($replacements as $key => $value) { |
56 | - $content = str_replace('{{' . mb_strtoupper($key) . '}}', $value, $content); |
|
56 | + $content = str_replace('{{'.mb_strtoupper($key).'}}', $value, $content); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | file_put_contents($destPath, $content); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | ]], |
97 | 97 | ]; |
98 | 98 | |
99 | - $assetContentType['fields'] = array_map(function ($field) { |
|
100 | - if (! isset($field['required'])) { |
|
99 | + $assetContentType['fields'] = array_map(function($field) { |
|
100 | + if (!isset($field['required'])) { |
|
101 | 101 | $field['required'] = true; |
102 | 102 | } |
103 | 103 | $field['disabled'] = false; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function fieldDefinition($table, $field): ?DefinitionInterface |
120 | 120 | { |
121 | - $className = '\Distilleries\Contentful\Commands\Generators\Definitions\\' . $field['type'] . 'Definition'; |
|
121 | + $className = '\Distilleries\Contentful\Commands\Generators\Definitions\\'.$field['type'].'Definition'; |
|
122 | 122 | |
123 | 123 | if (class_exists($className)) { |
124 | 124 | return new $className($table, $field); |
@@ -135,6 +135,6 @@ discard block |
||
135 | 135 | */ |
136 | 136 | protected function isFieldEnabled($field): bool |
137 | 137 | { |
138 | - return ! $field['disabled'] && ! $field['omitted']; |
|
138 | + return !$field['disabled'] && !$field['omitted']; |
|
139 | 139 | } |
140 | 140 | } |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | { |
26 | 26 | $contentTypes = $this->api->contentTypes(); |
27 | 27 | |
28 | - if (! empty($contentTypes['items'])) { |
|
28 | + if (!empty($contentTypes['items'])) { |
|
29 | 29 | array_unshift($contentTypes['items'], $this->assetContentType()); |
30 | 30 | |
31 | 31 | foreach ($contentTypes['items'] as $contentType) { |
32 | - $this->info('Content-Type: ' . mb_strtoupper($contentType['name'])); |
|
32 | + $this->info('Content-Type: '.mb_strtoupper($contentType['name'])); |
|
33 | 33 | $file = $this->createMapper($contentType); |
34 | - $this->line('Mapper "' . $file . '" created'); |
|
34 | + $this->line('Mapper "'.$file.'" created'); |
|
35 | 35 | $file = $this->createModel($contentType); |
36 | - $this->line('Model "' . $file . '" created'); |
|
36 | + $this->line('Model "'.$file.'" created'); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | $table = $this->tableName($contentType['sys']['id']); |
51 | 51 | $model = studly_case(str_singular($table)); |
52 | 52 | |
53 | - $stubPath = __DIR__ . '/stubs/model.stub'; |
|
54 | - $destPath = rtrim(config('contentful.generator.model'), '/') . '/' . $model . '.php'; |
|
53 | + $stubPath = __DIR__.'/stubs/model.stub'; |
|
54 | + $destPath = rtrim(config('contentful.generator.model'), '/').'/'.$model.'.php'; |
|
55 | 55 | |
56 | 56 | return static::writeStub($stubPath, $destPath, [ |
57 | 57 | 'model' => $model, |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | $table = $this->tableName($contentType['sys']['id']); |
72 | 72 | $model = studly_case(str_singular($table)); |
73 | 73 | |
74 | - $stubPath = __DIR__ . '/stubs/mapper.stub'; |
|
75 | - $destPath = rtrim(config('contentful.generator.mapper'), '/') . '/' . $model . 'Mapper.php'; |
|
74 | + $stubPath = __DIR__.'/stubs/mapper.stub'; |
|
75 | + $destPath = rtrim(config('contentful.generator.mapper'), '/').'/'.$model.'Mapper.php'; |
|
76 | 76 | |
77 | 77 | return static::writeStub($stubPath, $destPath, [ |
78 | 78 | 'model' => $model |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | return "\t\t//"; |
101 | 101 | } |
102 | 102 | |
103 | - return implode("\n\n", array_map(function ($getter) { |
|
103 | + return implode("\n\n", array_map(function($getter) { |
|
104 | 104 | return $getter; |
105 | 105 | }, $getters)); |
106 | 106 | } |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | { |
28 | 28 | $contentTypes = $this->api->contentTypes(); |
29 | 29 | |
30 | - if (! empty($contentTypes['items'])) { |
|
30 | + if (!empty($contentTypes['items'])) { |
|
31 | 31 | array_unshift($contentTypes['items'], $this->assetContentType()); |
32 | 32 | foreach ($contentTypes['items'] as $contentType) { |
33 | - $this->info('Content-Type: ' . mb_strtoupper($contentType['name'])); |
|
33 | + $this->info('Content-Type: '.mb_strtoupper($contentType['name'])); |
|
34 | 34 | $file = $this->createMigration($contentType); |
35 | - $this->line('Migration "' . $file . '" created'); |
|
35 | + $this->line('Migration "'.$file.'" created'); |
|
36 | 36 | sleep(1); |
37 | 37 | } |
38 | 38 | } |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | { |
50 | 50 | $table = $this->tableName($contentType['sys']['id']); |
51 | 51 | |
52 | - $stubPath = __DIR__ . '/stubs/migration.stub'; |
|
53 | - $destPath = database_path('migrations/' . Carbon::now()->format('Y_m_d_His') . '_create_' . $table . '_table.php'); |
|
52 | + $stubPath = __DIR__.'/stubs/migration.stub'; |
|
53 | + $destPath = database_path('migrations/'.Carbon::now()->format('Y_m_d_His').'_create_'.$table.'_table.php'); |
|
54 | 54 | |
55 | 55 | return static::writeStub($stubPath, $destPath, [ |
56 | 56 | 'class' => studly_case($table), |
@@ -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); |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | protected function dumpSync(bool $isPreview, string $connector = 'mysql'): string |
30 | 30 | { |
31 | - $path = storage_path('dumps/' . date('YmdHis') . '_sync' . ($isPreview ? '_preview' : '') . '.sql'); |
|
32 | - $this->warn('Dump "' . basename($path) . '"...'); |
|
31 | + $path = storage_path('dumps/'.date('YmdHis').'_sync'.($isPreview ? '_preview' : '').'.sql'); |
|
32 | + $this->warn('Dump "'.basename($path).'"...'); |
|
33 | 33 | |
34 | 34 | $dirName = dirname($path); |
35 | 35 | if (!is_dir($dirName)) { |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | $exec = 'export MYSQL_PWD=\'%s\'; mysqldump --add-drop-table --default-character-set=%s %s -u %s -h %s --port %s > %s'; |
54 | 54 | |
55 | 55 | $command = sprintf($exec, |
56 | - addcslashes(config('database.connections.' . $connector . '.password'), "'"), |
|
57 | - config('database.connections.' . $connector . '.charset'), |
|
58 | - config('database.connections.' . $connector . '.database'), |
|
59 | - config('database.connections.' . $connector . '.username'), |
|
60 | - config('database.connections.' . $connector . '.host'), |
|
61 | - config('database.connections.' . $connector . '.port'), |
|
56 | + addcslashes(config('database.connections.'.$connector.'.password'), "'"), |
|
57 | + config('database.connections.'.$connector.'.charset'), |
|
58 | + config('database.connections.'.$connector.'.database'), |
|
59 | + config('database.connections.'.$connector.'.username'), |
|
60 | + config('database.connections.'.$connector.'.host'), |
|
61 | + config('database.connections.'.$connector.'.port'), |
|
62 | 62 | $path |
63 | 63 | ); |
64 | 64 | exec($command); |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | |
67 | 67 | protected function getConnector(bool $isPreview, string $connector = 'mysql'): string |
68 | 68 | { |
69 | - $compiledConnector = $connector . ($isPreview ? '_preview' : ''); |
|
70 | - if (empty(config('database.connections.' . $compiledConnector . '.username'))) { |
|
69 | + $compiledConnector = $connector.($isPreview ? '_preview' : ''); |
|
70 | + if (empty(config('database.connections.'.$compiledConnector.'.username'))) { |
|
71 | 71 | $compiledConnector = $connector; |
72 | 72 | } |
73 | 73 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'database.default' => $compiledConnector, |
92 | 92 | ]); |
93 | 93 | |
94 | - $this->warn('Put into "' . $compiledConnector . '" database...'); |
|
94 | + $this->warn('Put into "'.$compiledConnector.'" database...'); |
|
95 | 95 | $this->putSql($path, $compiledConnector); |
96 | 96 | } |
97 | 97 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | $exec = 'export MYSQL_PWD=\'%s\'; mysql -u %s -h %s --port %s %s < %s'; |
108 | 108 | |
109 | 109 | $command = sprintf($exec, |
110 | - addcslashes(config('database.connections.' . $connector . '.password'), "'"), |
|
111 | - config('database.connections.' . $connector . '.username'), |
|
112 | - config('database.connections.' . $connector . '.host'), |
|
113 | - config('database.connections.' . $connector . '.port'), |
|
114 | - config('database.connections.' . $connector . '.database'), |
|
110 | + addcslashes(config('database.connections.'.$connector.'.password'), "'"), |
|
111 | + config('database.connections.'.$connector.'.username'), |
|
112 | + config('database.connections.'.$connector.'.host'), |
|
113 | + config('database.connections.'.$connector.'.port'), |
|
114 | + config('database.connections.'.$connector.'.database'), |
|
115 | 115 | $path |
116 | 116 | ); |
117 | 117 |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $bar = $this->createProgressBar($paginator->total()); |
145 | 145 | while ($paginator->isNotEmpty()) { |
146 | 146 | foreach ($paginator->items() as $item) { |
147 | - $bar->setMessage('Map entry ID: ' . $item->contentful_id); |
|
147 | + $bar->setMessage('Map entry ID: '.$item->contentful_id); |
|
148 | 148 | $this->mapItemToContentfulModel($item, $locales); |
149 | 149 | $bar->advance(); |
150 | 150 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $this->updateFromOtherThread($bar); |
170 | 170 | $items = collect(); |
171 | 171 | |
172 | - DB::transaction(function () use ($release, & $items) { |
|
172 | + DB::transaction(function() use ($release, & $items) { |
|
173 | 173 | $items = DB::table('sync_entries') |
174 | 174 | ->whereNull('release_id') |
175 | 175 | ->take(static::PER_BATCH) |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | $items = collect(); |
186 | 186 | } |
187 | 187 | |
188 | - $items->each(function ($item, $key) use ($locales, $bar) { |
|
189 | - $bar->setMessage('Map entry ID: ' . $item->contentful_id); |
|
188 | + $items->each(function($item, $key) use ($locales, $bar) { |
|
189 | + $bar->setMessage('Map entry ID: '.$item->contentful_id); |
|
190 | 190 | $this->mapItemToContentfulModel($item, $locales); |
191 | 191 | $bar->advance(); |
192 | 192 | }); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | $bar = $this->output->createProgressBar($total); |
228 | 228 | |
229 | - $bar->setFormat("%message%" . PHP_EOL . " %current%/%max% [%bar%] %percent:3s%%"); |
|
229 | + $bar->setFormat("%message%".PHP_EOL." %current%/%max% [%bar%] %percent:3s%%"); |
|
230 | 230 | |
231 | 231 | return $bar; |
232 | 232 | } |