Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach authored and github-actions[bot] committed Oct 1, 2024
1 parent 109649a commit b4bcf06
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
17 changes: 8 additions & 9 deletions src/Calendars/IslamicCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

namespace Spatie\Holidays\Calendars;

use Carbon\CarbonImmutable;
use Carbon\CarbonPeriod;
use Carbon\Exceptions\InvalidFormatException;
use DateTime;
use DateTimeZone;
use IntlCalendar;
use IntlDateFormatter;
use Carbon\CarbonPeriod;
use Carbon\CarbonImmutable;
use Carbon\Exceptions\InvalidFormatException;
use Spatie\Holidays\Countries\Country;
use Spatie\Holidays\Exceptions\InvalidYear;

/** @mixin Country */
trait IslamicCalendar
{
protected string $islamicCalendarTimezone = 'UTC';
protected string $islamicCalendarTimezone = 'UTC';

/** @return array<CarbonPeriod> */
public function eidAlFitr(int $year, int $totalDays = 3): array
Expand Down Expand Up @@ -144,7 +143,7 @@ protected function getOverlapping(array $collection, int $year, int $totalDays):

return null;
}

public function setIslamicCalendarTimezone(string $islamicCalendarTimezone): static
{
$this->islamicCalendarTimezone = $islamicCalendarTimezone;
Expand All @@ -168,9 +167,9 @@ protected function getHijriYear(int $year, bool $nextYear = false): int
{
$formatter = $this->getIslamicCalendarFormatter();
$formatter->setPattern('yyyy');
$dateTime = DateTime::createFromFormat('d/m/Y', '01/01/' . ($nextYear ? $year + 1 : $year));
$dateTime = DateTime::createFromFormat('d/m/Y', '01/01/'.($nextYear ? $year + 1 : $year));

if (!$dateTime) {
if (! $dateTime) {
throw InvalidYear::invalidHijriYear();
}

Expand All @@ -183,7 +182,7 @@ protected function islamicToGregorianDate(string $input, int $year, bool $nextYe
$formatter = $this->getIslamicCalendarFormatter();
$timestamp = (int) $formatter->parse(sprintf('%s-%s', $hijriYear, $input));

return (new CarbonImmutable())
return (new CarbonImmutable)
->setTimeStamp($timestamp)
->setTimezone(new DateTimeZone($this->islamicCalendarTimezone));
}
Expand Down
30 changes: 14 additions & 16 deletions src/Countries/Malaysia.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
class Malaysia extends Country
{
use ChineseCalendar;

use IslamicCalendar;

protected string $timezone = 'Asia/Kuala_Lumpur';

/** @var array<int, string> $regions */
/** @var array<int, string> */
protected array $regions = [
'jhr',
'kdh',
Expand All @@ -37,8 +36,7 @@ class Malaysia extends Country

protected function __construct(
protected ?string $region = null,
) {
}
) {}

public function countryCode(): string
{
Expand All @@ -48,11 +46,11 @@ public function countryCode(): string
protected function allHolidays(int $year): array
{
return array_merge([
'Hari Pekerja' => '05-01',
'Hari Kebangsaan' => '08-31',
'Hari Malaysia' => '09-16',
'Hari Krismas' => '12-25',
], $this->variableHolidays($year), $this->regionHolidays($year));
'Hari Pekerja' => '05-01',
'Hari Kebangsaan' => '08-31',
'Hari Malaysia' => '09-16',
'Hari Krismas' => '12-25',
], $this->variableHolidays($year), $this->regionHolidays($year));
}

/**
Expand Down Expand Up @@ -85,7 +83,7 @@ protected function variableHolidays(int $year): array
*/
protected function regionHolidays(int $year): array
{
if ($this->region && !$this->validRegion($this->region)) {
if ($this->region && ! $this->validRegion($this->region)) {
throw InvalidRegion::notFound($this->region);
}

Expand All @@ -99,7 +97,7 @@ protected function validRegion(string $region): bool

/**
* return holiday by region, if not set return all
*
*
* @return array<string, CarbonImmutable|string>
*/
protected function holidaysByRegion(int $year): array
Expand Down Expand Up @@ -164,7 +162,7 @@ protected function regionJohor(int $year): array
2026 => CarbonImmutable::createFromDate($year, 7, 21),
default => null,
};

if ($hariHolJohor) {
$johorHolidays['Hari Hol Johor'] = $hariHolJohor;
}
Expand Down Expand Up @@ -203,7 +201,7 @@ protected function regionKelantan(int $year): array
in_array($year, range(2010, 2022)) => CarbonImmutable::createFromDate($year, 11, 11),
in_array($year, range(2023, 2026)) => CarbonImmutable::createFromDate($year, 9, 29),
default => null,

};

if ($kingBirthday) {
Expand All @@ -215,7 +213,7 @@ protected function regionKelantan(int $year): array
in_array($year, range(2023, 2026)) => CarbonImmutable::createFromDate($year, 9, 30),
default => null,
};

if ($kingBirthdaySecondDay) {
$kelantanHolidays['Hari Keputeraan Sultan Kelantan Hari Kedua'] = $kingBirthdaySecondDay;
}
Expand Down Expand Up @@ -336,7 +334,7 @@ protected function regionPerlis(int $year): array
'Hari Deepavali' => '01-01',
];
}

/**
* @return array<string, CarbonImmutable|string>
*/
Expand Down Expand Up @@ -425,7 +423,7 @@ protected function pestaKaamatan(int $year): CarbonImmutable
protected function goodFriday(int $year): CarbonImmutable
{
$easter = $this->easter($year);

return $easter->subDays(2);
}

Expand Down

0 comments on commit b4bcf06

Please sign in to comment.