Skip to content

Commit

Permalink
Merge pull request #28 from devajmeireles/playground
Browse files Browse the repository at this point in the history
Introducing Basic Playground
  • Loading branch information
Nielsvanpach authored Jan 18, 2024
2 parents d09db5a + 81a4a61 commit a85d665
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
"ext-calendar": "*"
},
"require-dev": {
"laravel/prompts": "^0.1.15",
"pestphp/pest": "^2.31",
"phpstan/phpstan": "^1.10.56",
"spatie/ray": "^1.40.1"
"spatie/ray": "^1.40.1",
"symfony/var-dumper": "^6.4"
},
"autoload": {
"psr-4": {
Expand Down
30 changes: 30 additions & 0 deletions playground.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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);

0 comments on commit a85d665

Please sign in to comment.