use Illuminate\Console\Command;
class GithubLanguages extends Command
{
public function handle(): void
{
$this->info('retrieve all languages from ozh/github-colors');
$languages = Http::get('https://raw.githubusercontent.com/ozh/github-colors/master/colors.json')
->collect()
->put('VimL', ['color' => null])
->put('Arduino', ['color' => null])
->put('Eagle', ['color' => null])
->put('Nginx', ['color' => null])
->map(fn (array $language, string $name): array => array_merge(
$language,
[
'name' => $name,
'enum' => (string) Str::of($name)
->slug('_')
->upper(),
]
))
->map(fn (array $language): array => array_merge($language, [
'enum' => match ($language['name']) {
'C++' => 'C_PLUSPLUS',
'Objective-C++' => 'OBJECTIVE_C_PLUSPLUS',
'C#' => 'C_SHARP',
'F#' => 'F_SHARP',
'Q#' => 'Q_SHARP',
default => $language['enum'],
},
]))
->map(fn (array $language): array => Arr::only($language, ['name', 'enum', 'color']))
->sortBy('name')
->values();
//
}
}