Skip to content

Commit

Permalink
test: bump PHPStan to level 4
Browse files Browse the repository at this point in the history
  • Loading branch information
owenvoke committed Sep 5, 2024
1 parent 8acb327 commit 6daec56
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ parameters:
- src

# The level 8 is the highest level
level: 0
level: 4
7 changes: 5 additions & 2 deletions src/Calendars/YasumiUkCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,30 @@

use Carbon\Carbon;
use Worksome\UkTaxAllowance\Contracts\UkCalendar;
use Yasumi\Provider\AbstractProvider;
use Yasumi\Provider\UnitedKingdom;
use Yasumi\ProviderInterface;
use Yasumi\Yasumi;

class YasumiUkCalendar implements UkCalendar
{
protected const FUTURE = 1;
protected const PAST = -1;

/** {@inheritdoc} */
public function isWeekendDay(Carbon $date): bool
{
return $this->getCalendar($date)
->isWeekendDay($date);
}

/** {@inheritdoc} */
public function isHoliday(Carbon $date): bool
{
return $this->getCalendar($date)
->isHoliday($date);
}

/** {@inheritdoc} */
public function isWorkingDay(Carbon $date): bool
{
$ukCalendar = $this->getCalendar($date);
Expand Down Expand Up @@ -62,7 +65,7 @@ protected function closestWorkingDay(Carbon $date, int $direction): Carbon
return $workingDay;
}

private function getCalendar(Carbon $carbon): AbstractProvider
private function getCalendar(Carbon $carbon): ProviderInterface
{
return Yasumi::create(UnitedKingdom::class, $carbon->year);
}
Expand Down
5 changes: 3 additions & 2 deletions src/UkTaxAllowanceCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Worksome\UkTaxAllowance;

use Carbon\Carbon;
use Carbon\CarbonInterface;
use Carbon\CarbonInterval;
use Carbon\CarbonPeriod;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -43,7 +44,7 @@ public function weeklyEndDatesBetween(Carbon $start, Carbon $end): Collection
/**
* Returns the month end dates used for allowance count
*
* @return Collection<Carbon>
* @return Collection<CarbonInterface>
*/
public function monthlyEndDatesBetween(Carbon $start, Carbon $end): Collection
{
Expand Down Expand Up @@ -71,7 +72,7 @@ public function monthlyEndDatesBetween(Carbon $start, Carbon $end): Collection

public function weekly(Carbon $start, Carbon $end): int
{
return collect($this->weeklyEndDatesBetween($start, $end))->count();
return $this->weeklyEndDatesBetween($start, $end)->count();
}

public function monthly(Carbon $start, Carbon $end): int
Expand Down
11 changes: 9 additions & 2 deletions src/UkTaxAllowanceServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

namespace Worksome\UkTaxAllowance;

use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
use Worksome\UkTaxAllowance\Calendars\YasumiUkCalendar;
use Worksome\UkTaxAllowance\Contracts\UkCalendar;

class UkTaxAllowanceServiceProvider extends ServiceProvider
class UkTaxAllowanceServiceProvider extends ServiceProvider implements DeferrableProvider
{
public function register()
public function register(): void
{
$this->app->bind(UkCalendar::class, function () {
return new YasumiUkCalendar();
});
}

/** @return array<class-string> */
public function provides(): array
{
return [UkCalendar::class];
}
}

0 comments on commit 6daec56

Please sign in to comment.