forked from spatie/holidays
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playground.php
31 lines (21 loc) · 834 Bytes
/
playground.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
use Spatie\Holidays\Countries\Country;
use Spatie\Holidays\Holidays;
use function Laravel\Prompts\select;
require __DIR__.'/vendor/autoload.php';
$countries = [];
foreach (glob(__DIR__.'/src/Countries/*.php') as $filename) { // @phpstan-ignore-line
$countryClass = '\\Spatie\\Holidays\\Countries\\'.basename($filename, '.php');
if (basename($filename) === 'Country.php') {
continue;
}
$countries[$countryClass] = str_replace('\\Spatie\\Holidays\\Countries\\', '', $countryClass);
}
/** @var Country $class */
$class = select('Select a country', $countries);
$result = collect(Holidays::for($class::make())->get())
->map(fn (array $holiday) => [
'name' => $holiday['name'],
'date' => $holiday['date']->format('Y-m-d'), // @phpstan-ignore-line
])->toArray();
dd($result);