CountrySeeder::run()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 252
Code Lines 248

Duplication

Lines 0
Ratio 0 %

Importance

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

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 CleaniqueCoders\Profile\Database\Seeders;
4
5
use Illuminate\Database\Seeder;
6
use Illuminate\Support\Str;
7
8
class CountrySeeder extends Seeder
9
{
10
    /**
11
     * Run the database seeds.
12
     */
13
    public function run()
14
    {
15
        $countries = [
16
            'AF' => 'Afghanistan',
17
            'AL' => 'Albania',
18
            'DZ' => 'Algeria',
19
            'AS' => 'American Samoa',
20
            'AD' => 'Andorra',
21
            'AO' => 'Angola',
22
            'AI' => 'Anguilla',
23
            'AQ' => 'Antarctica',
24
            'AG' => 'Antigua And Barbuda',
25
            'AR' => 'Argentina',
26
            'AM' => 'Armenia',
27
            'AW' => 'Aruba',
28
            'AU' => 'Australia',
29
            'AT' => 'Austria',
30
            'AZ' => 'Azerbaijan',
31
            'BS' => 'Bahamas',
32
            'BH' => 'Bahrain',
33
            'BD' => 'Bangladesh',
34
            'BB' => 'Barbados',
35
            'BY' => 'Belarus',
36
            'BE' => 'Belgium',
37
            'BZ' => 'Belize',
38
            'BJ' => 'Benin',
39
            'BM' => 'Bermuda',
40
            'BT' => 'Bhutan',
41
            'BO' => 'Bolivia',
42
            'BA' => 'Bosnia And Herzegovina',
43
            'BW' => 'Botswana',
44
            'BV' => 'Bouvet Island',
45
            'BR' => 'Brazil',
46
            'IO' => 'British Indian Ocean Territory',
47
            'BN' => 'Brunei Darussalam',
48
            'BG' => 'Bulgaria',
49
            'BF' => 'Burkina Faso',
50
            'BI' => 'Burundi',
51
            'KH' => 'Cambodia',
52
            'CM' => 'Cameroon',
53
            'CA' => 'Canada',
54
            'CV' => 'Cape Verde',
55
            'KY' => 'Cayman Islands',
56
            'CF' => 'Central African Republic',
57
            'TD' => 'Chad',
58
            'CL' => 'Chile',
59
            'CN' => 'China',
60
            'CX' => 'Christmas Island',
61
            'CC' => 'Cocos (keeling) Islands',
62
            'CO' => 'Colombia',
63
            'KM' => 'Comoros',
64
            'CG' => 'Congo',
65
            'CD' => 'Congo, The Democratic Republic Of The',
66
            'CK' => 'Cook Islands',
67
            'CR' => 'Costa Rica',
68
            'CI' => 'Cote D\'ivoire',
69
            'HR' => 'Croatia',
70
            'CU' => 'Cuba',
71
            'CY' => 'Cyprus',
72
            'CZ' => 'Czech Republic',
73
            'DK' => 'Denmark',
74
            'DJ' => 'Djibouti',
75
            'DM' => 'Dominica',
76
            'DO' => 'Dominican Republic',
77
            'TP' => 'East Timor',
78
            'EC' => 'Ecuador',
79
            'EG' => 'Egypt',
80
            'SV' => 'El Salvador',
81
            'GQ' => 'Equatorial Guinea',
82
            'ER' => 'Eritrea',
83
            'EE' => 'Estonia',
84
            'ET' => 'Ethiopia',
85
            'FK' => 'Falkland Islands (malvinas)',
86
            'FO' => 'Faroe Islands',
87
            'FJ' => 'Fiji',
88
            'FI' => 'Finland',
89
            'FR' => 'France',
90
            'GF' => 'French Guiana',
91
            'PF' => 'French Polynesia',
92
            'TF' => 'French Southern Territories',
93
            'GA' => 'Gabon',
94
            'GM' => 'Gambia',
95
            'GE' => 'Georgia',
96
            'DE' => 'Germany',
97
            'GH' => 'Ghana',
98
            'GI' => 'Gibraltar',
99
            'GR' => 'Greece',
100
            'GL' => 'Greenland',
101
            'GD' => 'Grenada',
102
            'GP' => 'Guadeloupe',
103
            'GU' => 'Guam',
104
            'GT' => 'Guatemala',
105
            'GN' => 'Guinea',
106
            'GW' => 'Guinea-bissau',
107
            'GY' => 'Guyana',
108
            'HT' => 'Haiti',
109
            'HM' => 'Heard Island And Mcdonald Islands',
110
            'VA' => 'Holy See (vatican City State)',
111
            'HN' => 'Honduras',
112
            'HK' => 'Hong Kong',
113
            'HU' => 'Hungary',
114
            'IS' => 'Iceland',
115
            'IN' => 'India',
116
            'ID' => 'Indonesia',
117
            'IR' => 'Iran, Islamic Republic Of',
118
            'IQ' => 'Iraq',
119
            'IE' => 'Ireland',
120
            'IL' => 'Israel',
121
            'IT' => 'Italy',
122
            'JM' => 'Jamaica',
123
            'JP' => 'Japan',
124
            'JO' => 'Jordan',
125
            'KZ' => 'Kazakstan',
126
            'KE' => 'Kenya',
127
            'KI' => 'Kiribati',
128
            'KP' => 'Korea, Democratic People\'s Republic Of',
129
            'KR' => 'Korea, Republic Of',
130
            'KV' => 'Kosovo',
131
            'KW' => 'Kuwait',
132
            'KG' => 'Kyrgyzstan',
133
            'LA' => 'Lao People\'s Democratic Republic',
134
            'LV' => 'Latvia',
135
            'LB' => 'Lebanon',
136
            'LS' => 'Lesotho',
137
            'LR' => 'Liberia',
138
            'LY' => 'Libyan Arab Jamahiriya',
139
            'LI' => 'Liechtenstein',
140
            'LT' => 'Lithuania',
141
            'LU' => 'Luxembourg',
142
            'MO' => 'Macau',
143
            'MK' => 'Macedonia, The Former Yugoslav Republic Of',
144
            'MG' => 'Madagascar',
145
            'MW' => 'Malawi',
146
            'MY' => 'Malaysia',
147
            'MV' => 'Maldives',
148
            'ML' => 'Mali',
149
            'MT' => 'Malta',
150
            'MH' => 'Marshall Islands',
151
            'MQ' => 'Martinique',
152
            'MR' => 'Mauritania',
153
            'MU' => 'Mauritius',
154
            'YT' => 'Mayotte',
155
            'MX' => 'Mexico',
156
            'FM' => 'Micronesia, Federated States Of',
157
            'MD' => 'Moldova, Republic Of',
158
            'MC' => 'Monaco',
159
            'MN' => 'Mongolia',
160
            'MS' => 'Montserrat',
161
            'ME' => 'Montenegro',
162
            'MA' => 'Morocco',
163
            'MZ' => 'Mozambique',
164
            'MM' => 'Myanmar',
165
            'NA' => 'Namibia',
166
            'NR' => 'Nauru',
167
            'NP' => 'Nepal',
168
            'NL' => 'Netherlands',
169
            'AN' => 'Netherlands Antilles',
170
            'NC' => 'New Caledonia',
171
            'NZ' => 'New Zealand',
172
            'NI' => 'Nicaragua',
173
            'NE' => 'Niger',
174
            'NG' => 'Nigeria',
175
            'NU' => 'Niue',
176
            'NF' => 'Norfolk Island',
177
            'MP' => 'Northern Mariana Islands',
178
            'NO' => 'Norway',
179
            'OM' => 'Oman',
180
            'PK' => 'Pakistan',
181
            'PW' => 'Palau',
182
            'PS' => 'Palestinian Territory, Occupied',
183
            'PA' => 'Panama',
184
            'PG' => 'Papua New Guinea',
185
            'PY' => 'Paraguay',
186
            'PE' => 'Peru',
187
            'PH' => 'Philippines',
188
            'PN' => 'Pitcairn',
189
            'PL' => 'Poland',
190
            'PT' => 'Portugal',
191
            'PR' => 'Puerto Rico',
192
            'QA' => 'Qatar',
193
            'RE' => 'Reunion',
194
            'RO' => 'Romania',
195
            'RU' => 'Russian Federation',
196
            'RW' => 'Rwanda',
197
            'SH' => 'Saint Helena',
198
            'KN' => 'Saint Kitts And Nevis',
199
            'LC' => 'Saint Lucia',
200
            'PM' => 'Saint Pierre And Miquelon',
201
            'VC' => 'Saint Vincent And The Grenadines',
202
            'WS' => 'Samoa',
203
            'SM' => 'San Marino',
204
            'ST' => 'Sao Tome And Principe',
205
            'SA' => 'Saudi Arabia',
206
            'SN' => 'Senegal',
207
            'RS' => 'Serbia',
208
            'SC' => 'Seychelles',
209
            'SL' => 'Sierra Leone',
210
            'SG' => 'Singapore',
211
            'SK' => 'Slovakia',
212
            'SI' => 'Slovenia',
213
            'SB' => 'Solomon Islands',
214
            'SO' => 'Somalia',
215
            'ZA' => 'South Africa',
216
            'GS' => 'South Georgia And The South Sandwich Islands',
217
            'ES' => 'Spain',
218
            'LK' => 'Sri Lanka',
219
            'SD' => 'Sudan',
220
            'SR' => 'Suriname',
221
            'SJ' => 'Svalbard And Jan Mayen',
222
            'SZ' => 'Swaziland',
223
            'SE' => 'Sweden',
224
            'CH' => 'Switzerland',
225
            'SY' => 'Syrian Arab Republic',
226
            'TW' => 'Taiwan, Province Of China',
227
            'TJ' => 'Tajikistan',
228
            'TZ' => 'Tanzania, United Republic Of',
229
            'TH' => 'Thailand',
230
            'TG' => 'Togo',
231
            'TK' => 'Tokelau',
232
            'TO' => 'Tonga',
233
            'TT' => 'Trinidad And Tobago',
234
            'TN' => 'Tunisia',
235
            'TR' => 'Turkey',
236
            'TM' => 'Turkmenistan',
237
            'TC' => 'Turks And Caicos Islands',
238
            'TV' => 'Tuvalu',
239
            'UG' => 'Uganda',
240
            'UA' => 'Ukraine',
241
            'AE' => 'United Arab Emirates',
242
            'GB' => 'United Kingdom',
243
            'US' => 'United States',
244
            'UM' => 'United States Minor Outlying Islands',
245
            'UY' => 'Uruguay',
246
            'UZ' => 'Uzbekistan',
247
            'VU' => 'Vanuatu',
248
            'VE' => 'Venezuela',
249
            'VN' => 'Viet Nam',
250
            'VG' => 'Virgin Islands, British',
251
            'VI' => 'Virgin Islands, U.s.',
252
            'WF' => 'Wallis And Futuna',
253
            'EH' => 'Western Sahara',
254
            'YE' => 'Yemen',
255
            'ZM' => 'Zambia',
256
            'ZW' => 'Zimbabwe',
257
        ];
258
259
        foreach ($countries as $code => $name) {
260
            \CleaniqueCoders\Profile\Models\Country::create([
261
                'uuid' => Str::orderedUuid(),
262
                'code' => $code,
263
                'name' => $name,
264
                'label' => Str::slug($name, '-'),
265
            ]);
266
        }
267
    }
268
}
269