Passed
Branch main (ec0923)
by Seth
01:27
created

2022_12_10_185600_seed_languages.php$0 ➔ up()   B

Complexity

Conditions 2
Paths 1

Size

Total Lines 248
Code Lines 242

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 242
nc 1
nop 0
dl 0
loc 248
rs 8
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace SaasReady\Database\Migrations;
4
5
use Illuminate\Database\Migrations\Migration;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Migrations\Migration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Support\Facades\DB;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Facades\DB was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Illuminate\Support\Str;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Str was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use SaasReady\Constants\LanguageCode;
9
use SaasReady\Models\Language;
0 ignored issues
show
Bug introduced by
The type SaasReady\Models\Language was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
return new class () extends Migration {
12
    public function up(): void
13
    {
14
        $labels = [
15
            'af' => 'Afrikaans',
16
            'af-ZA' => 'Afrikaans (South Africa)',
17
            'ar' => 'Arabic',
18
            'ar-AE' => 'Arabic (U.A.E.)',
19
            'ar-BH' => 'Arabic (Bahrain)',
20
            'ar-DZ' => 'Arabic (Algeria)',
21
            'ar-EG' => 'Arabic (Egypt)',
22
            'ar-IQ' => 'Arabic (Iraq)',
23
            'ar-JO' => 'Arabic (Jordan)',
24
            'ar-KW' => 'Arabic (Kuwait)',
25
            'ar-LB' => 'Arabic (Lebanon)',
26
            'ar-LY' => 'Arabic (Libya)',
27
            'ar-MA' => 'Arabic (Morocco)',
28
            'ar-OM' => 'Arabic (Oman)',
29
            'ar-QA' => 'Arabic (Qatar)',
30
            'ar-SA' => 'Arabic (Saudi Arabia)',
31
            'ar-SY' => 'Arabic (Syria)',
32
            'ar-TN' => 'Arabic (Tunisia)',
33
            'ar-YE' => 'Arabic (Yemen)',
34
            'az' => 'Azeri (Latin)',
35
            'az-AZ' => 'Azeri (Cyrillic) (Azerbaijan)',
36
            'be' => 'Belarusian',
37
            'be-BY' => 'Belarusian (Belarus)',
38
            'bg' => 'Bulgarian',
39
            'bg-BG' => 'Bulgarian (Bulgaria)',
40
            'bs-BA' => 'Bosnian (Bosnia and Herzegovina)',
41
            'ca' => 'Catalan',
42
            'ca-ES' => 'Catalan (Spain)',
43
            'cs' => 'Czech',
44
            'cs-CZ' => 'Czech (Czech Republic)',
45
            'cy' => 'Welsh',
46
            'cy-GB' => 'Welsh (United Kingdom)',
47
            'da' => 'Danish',
48
            'da-DK' => 'Danish (Denmark)',
49
            'de' => 'German',
50
            'de-AT' => 'German (Austria)',
51
            'de-CH' => 'German (Switzerland)',
52
            'de-DE' => 'German (Germany)',
53
            'de-LI' => 'German (Liechtenstein)',
54
            'de-LU' => 'German (Luxembourg)',
55
            'dv' => 'Divehi',
56
            'dv-MV' => 'Divehi (Maldives)',
57
            'el' => 'Greek',
58
            'el-GR' => 'Greek (Greece)',
59
            'en' => 'English',
60
            'en-AU' => 'English (Australia)',
61
            'en-BZ' => 'English (Belize)',
62
            'en-CA' => 'English (Canada)',
63
            'en-CB' => 'English (Caribbean)',
64
            'en-GB' => 'English (United Kingdom)',
65
            'en-IE' => 'English (Ireland)',
66
            'en-JM' => 'English (Jamaica)',
67
            'en-NZ' => 'English (New Zealand)',
68
            'en-PH' => 'English (Republic of the Philippines)',
69
            'en-TT' => 'English (Trinidad and Tobago)',
70
            'en-US' => 'English (United States)',
71
            'en-ZA' => 'English (South Africa)',
72
            'en-ZW' => 'English (Zimbabwe)',
73
            'eo' => 'Esperanto',
74
            'es' => 'Spanish',
75
            'es-AR' => 'Spanish (Argentina)',
76
            'es-BO' => 'Spanish (Bolivia)',
77
            'es-CL' => 'Spanish (Chile)',
78
            'es-CO' => 'Spanish (Colombia)',
79
            'es-CR' => 'Spanish (Costa Rica)',
80
            'es-DO' => 'Spanish (Dominican Republic)',
81
            'es-EC' => 'Spanish (Ecuador)',
82
            'es-ES' => 'Spanish (Spain)',
83
            'es-GT' => 'Spanish (Guatemala)',
84
            'es-HN' => 'Spanish (Honduras)',
85
            'es-MX' => 'Spanish (Mexico)',
86
            'es-NI' => 'Spanish (Nicaragua)',
87
            'es-PA' => 'Spanish (Panama)',
88
            'es-PE' => 'Spanish (Peru)',
89
            'es-PR' => 'Spanish (Puerto Rico)',
90
            'es-PY' => 'Spanish (Paraguay)',
91
            'es-SV' => 'Spanish (El Salvador)',
92
            'es-UY' => 'Spanish (Uruguay)',
93
            'es-VE' => 'Spanish (Venezuela)',
94
            'et' => 'Estonian',
95
            'et-EE' => 'Estonian (Estonia)',
96
            'eu' => 'Basque',
97
            'eu-ES' => 'Basque (Spain)',
98
            'fa' => 'Farsi',
99
            'fa-IR' => 'Farsi (Iran)',
100
            'fi' => 'Finnish',
101
            'fi-FI' => 'Finnish (Finland)',
102
            'fo' => 'Faroese',
103
            'fo-FO' => 'Faroese (Faroe Islands)',
104
            'fr' => 'French',
105
            'fr-BE' => 'French (Belgium)',
106
            'fr-CA' => 'French (Canada)',
107
            'fr-CH' => 'French (Switzerland)',
108
            'fr-FR' => 'French (France)',
109
            'fr-LU' => 'French (Luxembourg)',
110
            'fr-MC' => 'French (Principality of Monaco)',
111
            'gl' => 'Galician',
112
            'gl-ES' => 'Galician (Spain)',
113
            'gu' => 'Gujarati',
114
            'gu-IN' => 'Gujarati (India)',
115
            'he' => 'Hebrew',
116
            'he-IL' => 'Hebrew (Israel)',
117
            'hi' => 'Hindi',
118
            'hi-IN' => 'Hindi (India)',
119
            'hr' => 'Croatian',
120
            'hr-BA' => 'Croatian (Bosnia and Herzegovina)',
121
            'hr-HR' => 'Croatian (Croatia)',
122
            'hu' => 'Hungarian',
123
            'hu-HU' => 'Hungarian (Hungary)',
124
            'hy' => 'Armenian',
125
            'hy-AM' => 'Armenian (Armenia)',
126
            'id' => 'Indonesian',
127
            'id-ID' => 'Indonesian (Indonesia)',
128
            'is' => 'Icelandic',
129
            'is-IS' => 'Icelandic (Iceland)',
130
            'it' => 'Italian',
131
            'it-CH' => 'Italian (Switzerland)',
132
            'it-IT' => 'Italian (Italy)',
133
            'ja' => 'Japanese',
134
            'ja-JP' => 'Japanese (Japan)',
135
            'ka' => 'Georgian',
136
            'ka-GE' => 'Georgian (Georgia)',
137
            'kk' => 'Kazakh',
138
            'kk-KZ' => 'Kazakh (Kazakhstan)',
139
            'kn' => 'Kannada',
140
            'kn-IN' => 'Kannada (India)',
141
            'ko' => 'Korean',
142
            'ko-KR' => 'Korean (Korea)',
143
            'kok' => 'Konkani',
144
            'kok-IN' => 'Konkani (India)',
145
            'ky' => 'Kyrgyz',
146
            'ky-KG' => 'Kyrgyz (Kyrgyzstan)',
147
            'lt' => 'Lithuanian',
148
            'lt-LT' => 'Lithuanian (Lithuania)',
149
            'lv' => 'Latvian',
150
            'lv-LV' => 'Latvian (Latvia)',
151
            'mi' => 'Maori',
152
            'mi-NZ' => 'Maori (New Zealand)',
153
            'mk' => 'FYRO Macedonian',
154
            'mk-MK' => 'FYRO Macedonian (Former Yugoslav Republic of Macedonia)',
155
            'mn' => 'Mongolian',
156
            'mn-MN' => 'Mongolian (Mongolia)',
157
            'mr' => 'Marathi',
158
            'mr-IN' => 'Marathi (India)',
159
            'ms' => 'Malay',
160
            'ms-BN' => 'Malay (Brunei Darussalam)',
161
            'ms-MY' => 'Malay (Malaysia)',
162
            'mt' => 'Maltese',
163
            'mt-MT' => 'Maltese (Malta)',
164
            'nb' => 'Norwegian (Bokm?l)',
165
            'nb-NO' => 'Norwegian (Bokm?l) (Norway)',
166
            'nl' => 'Dutch',
167
            'nl-BE' => 'Dutch (Belgium)',
168
            'nl-NL' => 'Dutch (Netherlands)',
169
            'nn-NO' => 'Norwegian (Nynorsk) (Norway)',
170
            'ns' => 'Northern Sotho',
171
            'ns-ZA' => 'Northern Sotho (South Africa)',
172
            'pa' => 'Punjabi',
173
            'pa-IN' => 'Punjabi (India)',
174
            'pl' => 'Polish',
175
            'pl-PL' => 'Polish (Poland)',
176
            'ps' => 'Pashto',
177
            'ps-AR' => 'Pashto (Afghanistan)',
178
            'pt' => 'Portuguese',
179
            'pt-BR' => 'Portuguese (Brazil)',
180
            'pt-PT' => 'Portuguese (Portugal)',
181
            'qu' => 'Quechua',
182
            'qu-BO' => 'Quechua (Bolivia)',
183
            'qu-EC' => 'Quechua (Ecuador)',
184
            'qu-PE' => 'Quechua (Peru)',
185
            'ro' => 'Romanian',
186
            'ro-RO' => 'Romanian (Romania)',
187
            'ru' => 'Russian',
188
            'ru-RU' => 'Russian (Russia)',
189
            'sa' => 'Sanskrit',
190
            'sa-IN' => 'Sanskrit (India)',
191
            'se' => 'Sami (Northern)',
192
            'se-FI' => 'Sami (Inari) (Finland)',
193
            'se-NO' => 'Sami (Southern) (Norway)',
194
            'se-SE' => 'Sami (Southern) (Sweden)',
195
            'sk' => 'Slovak',
196
            'sk-SK' => 'Slovak (Slovakia)',
197
            'sl' => 'Slovenian',
198
            'sl-SI' => 'Slovenian (Slovenia)',
199
            'sq' => 'Albanian',
200
            'sq-AL' => 'Albanian (Albania)',
201
            'sr-BA' => 'Serbian (Cyrillic) (Bosnia and Herzegovina)',
202
            'sr-SP' => 'Serbian (Cyrillic) (Serbia and Montenegro)',
203
            'sv' => 'Swedish',
204
            'sv-FI' => 'Swedish (Finland)',
205
            'sv-SE' => 'Swedish (Sweden)',
206
            'sw' => 'Swahili',
207
            'sw-KE' => 'Swahili (Kenya)',
208
            'syr' => 'Syriac',
209
            'syr-SY' => 'Syriac (Syria)',
210
            'ta' => 'Tamil',
211
            'ta-IN' => 'Tamil (India)',
212
            'te' => 'Telugu',
213
            'te-IN' => 'Telugu (India)',
214
            'th' => 'Thai',
215
            'th-TH' => 'Thai (Thailand)',
216
            'tl' => 'Tagalog',
217
            'tl-PH' => 'Tagalog (Philippines)',
218
            'tn' => 'Tswana',
219
            'tn-ZA' => 'Tswana (South Africa)',
220
            'tr' => 'Turkish',
221
            'tr-TR' => 'Turkish (Turkey)',
222
            'tt' => 'Tatar',
223
            'tt-RU' => 'Tatar (Russia)',
224
            'ts' => 'Tsonga',
225
            'uk' => 'Ukrainian',
226
            'uk-UA' => 'Ukrainian (Ukraine)',
227
            'ur' => 'Urdu',
228
            'ur-PK' => 'Urdu (Islamic Republic of Pakistan)',
229
            'uz' => 'Uzbek (Latin)',
230
            'uz-UZ' => 'Uzbek (Cyrillic) (Uzbekistan)',
231
            'vi' => 'Vietnamese',
232
            'vi-VN' => 'Vietnamese (Viet Nam)',
233
            'xh' => 'Xhosa',
234
            'xh-ZA' => 'Xhosa (South Africa)',
235
            'zh' => 'Chinese',
236
            'zh-CN' => 'Chinese (China)',
237
            'zh-HK' => 'Chinese (Hong Kong)',
238
            'zh-MO' => 'Chinese (Macau)',
239
            'zh-SG' => 'Chinese (Singapore)',
240
            'zh-TW' => 'Chinese (Taiwan)',
241
            'zu' => 'Zulu',
242
            'zu-ZA' => 'Zulu (South Africa)',
243
        ];
244
245
        $languages = array_map(function (LanguageCode $langCode) use ($labels) {
246
            return [
247
                'uuid' => Str::orderedUuid(),
248
                'code' => $langCode->value,
249
                'name' => $labels[$langCode->value],
250
                'activated_at' => $langCode === LanguageCode::ENGLISH
251
                    ? now()
0 ignored issues
show
Bug introduced by
The function now was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

251
                    ? /** @scrutinizer ignore-call */ now()
Loading history...
252
                    : null,
253
                'created_at' => now(),
254
                'updated_at' => now(),
255
            ];
256
        }, LanguageCode::cases());
257
258
        DB::table((new Language())->getTable())
259
            ->insert($languages);
260
    }
261
262
    public function down(): void
263
    {
264
        // 1 way
265
    }
266
};
267