Skip to content

Commit

Permalink
rename all() to get()
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach committed Jan 15, 2024
1 parent d459fe6 commit 5ef3d7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Holidays.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function new(): static
}

/** @return array<array{name: string, date: string}> */
public static function all(?string $country = null, ?int $year = null): array
public static function get(?string $country = null, ?int $year = null): array
{
$country = is_string($country) ? Country::findOrFail($country) : null;

Expand Down
14 changes: 7 additions & 7 deletions tests/HolidaysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@
it('can get all holidays of the current year', function () {
CarbonImmutable::setTestNow('2024-01-01');

$holidays = Holidays::all();
$holidays = Holidays::get();

expect($holidays)->toMatchSnapshot();
});

it('can get all holidays of 2023', function () {
$holidays = Holidays::all(year: 2023);
$holidays = Holidays::get(year: 2023);

expect($holidays)->toMatchSnapshot();
});

it('can get all holidays of 2025', function () {
$holidays = Holidays::all(year: 2025);
$holidays = Holidays::get(year: 2025);

expect($holidays)->toMatchSnapshot();
});

it('can get all holidays of another year and a specific country', function () {
$holidays = Holidays::all(country: 'be', year: 2024);
$holidays = Holidays::get(country: 'be', year: 2024);

expect($holidays)->toMatchSnapshot();
});

it('cannot get all holidays of an unknown country code', function () {
Holidays::all(country: 'unknown');
Holidays::get(country: 'unknown');
})->throws(UnsupportedCountry::class);

it('cannot get holidays for years before 1970', function () {
Holidays::all(year: 1969);
Holidays::get(year: 1969);
})->throws(InvalidYear::class, 'Holidays can only be calculated for years after 1970.');

it('cannot get holidays for years after 2037', function () {
Holidays::all(year: 2038);
Holidays::get(year: 2038);
})->throws(InvalidYear::class, 'Holidays can only be calculated for years before 2038');

it('can see if a date is a holiday', function () {
Expand Down

0 comments on commit 5ef3d7b

Please sign in to comment.