Skip to content

Commit 83889cb

Browse files
committed
refactor: replace FQCNs with class imports
Use proper import statements instead of fully qualified class names throughout the codebase for better readability and consistency. Made-with: Cursor
1 parent a00b533 commit 83889cb

34 files changed

Lines changed: 282 additions & 218 deletions

config/zap.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

33
use Carbon\CarbonInterface;
4+
use Zap\Enums\ScheduleTypes;
5+
use Zap\Models\Schedule;
6+
use Zap\Models\SchedulePeriod;
47

58
return [
69
/*
@@ -29,8 +32,8 @@
2932
'enabled' => true,
3033
'applies_to' => [
3134
// Which schedule types get this rule automatically
32-
\Zap\Enums\ScheduleTypes::APPOINTMENT,
33-
\Zap\Enums\ScheduleTypes::BLOCKED,
35+
ScheduleTypes::APPOINTMENT,
36+
ScheduleTypes::BLOCKED,
3437
],
3538
],
3639
'working_hours' => [
@@ -99,7 +102,7 @@
99102
|
100103
*/
101104
'models' => [
102-
'schedule' => \Zap\Models\Schedule::class,
103-
'schedule_period' => \Zap\Models\SchedulePeriod::class,
105+
'schedule' => Schedule::class,
106+
'schedule_period' => SchedulePeriod::class,
104107
],
105108
];

src/Data/DailyFrequencyConfig.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@
22

33
namespace Zap\Data;
44

5+
use Carbon\CarbonInterface;
56
use Zap\Models\Schedule;
67

78
class DailyFrequencyConfig extends FrequencyConfig
89
{
9-
public static function fromArray(array $data): \Zap\Data\FrequencyConfig
10+
public static function fromArray(array $data): FrequencyConfig
1011
{
1112
return new self;
1213
}
1314

14-
public function getNextRecurrence(\Carbon\CarbonInterface $current): \Carbon\CarbonInterface
15+
public function getNextRecurrence(CarbonInterface $current): CarbonInterface
1516
{
1617
return $current->copy()->addDay();
1718
}
1819

19-
public function shouldCreateInstance(\Carbon\CarbonInterface $date): bool
20+
public function shouldCreateInstance(CarbonInterface $date): bool
2021
{
2122
return true;
2223
}
2324

24-
public function shouldCreateRecurringInstance(Schedule $schedule, \Carbon\CarbonInterface $date): bool
25+
public function shouldCreateRecurringInstance(Schedule $schedule, CarbonInterface $date): bool
2526
{
2627
return true;
2728
}

src/Data/FrequencyConfig.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22

33
namespace Zap\Data;
44

5+
use Carbon\CarbonInterface;
56
use Illuminate\Contracts\Support\Arrayable;
67
use Zap\Models\Schedule;
78

89
abstract class FrequencyConfig implements Arrayable
910
{
1011
abstract public static function fromArray(array $data): self;
1112

12-
abstract public function getNextRecurrence(\Carbon\CarbonInterface $current): \Carbon\CarbonInterface;
13+
abstract public function getNextRecurrence(CarbonInterface $current): CarbonInterface;
1314

14-
public function setStartFromStartDate(\Carbon\CarbonInterface $startDate): self
15+
public function setStartFromStartDate(CarbonInterface $startDate): self
1516
{
1617
return $this;
1718
}
1819

19-
abstract public function shouldCreateInstance(\Carbon\CarbonInterface $date): bool;
20+
abstract public function shouldCreateInstance(CarbonInterface $date): bool;
2021

21-
abstract public function shouldCreateRecurringInstance(Schedule $schedule, \Carbon\CarbonInterface $date): bool;
22+
abstract public function shouldCreateRecurringInstance(Schedule $schedule, CarbonInterface $date): bool;
2223

2324
public function toArray(): array
2425
{

src/Data/MonthlyFrequencyConfig/AbstractMonthlyFrequencyConfig.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Zap\Data\MonthlyFrequencyConfig;
44

5+
use Carbon\CarbonInterface;
56
use Zap\Data\FrequencyConfig;
67
use Zap\Models\Schedule;
78

@@ -30,7 +31,7 @@ public static function fromArray(array $data): static
3031
);
3132
}
3233

33-
public function setStartFromStartDate(\Carbon\CarbonInterface $startDate): self
34+
public function setStartFromStartDate(CarbonInterface $startDate): self
3435
{
3536
if ($this->start_month === null) {
3637
$this->start_month = $startDate->month;
@@ -39,7 +40,7 @@ public function setStartFromStartDate(\Carbon\CarbonInterface $startDate): self
3940
return $this;
4041
}
4142

42-
public function getNextRecurrence(\Carbon\CarbonInterface $current): \Carbon\CarbonInterface
43+
public function getNextRecurrence(CarbonInterface $current): CarbonInterface
4344
{
4445
$daysOfMonth = $this->days_of_month ?? [$current->day];
4546
if ($current->day >= max($daysOfMonth)) {
@@ -52,15 +53,15 @@ public function getNextRecurrence(\Carbon\CarbonInterface $current): \Carbon\Car
5253
return $current->copy()->day($dayOfMonth);
5354
}
5455

55-
public function shouldCreateInstance(\Carbon\CarbonInterface $date): bool
56+
public function shouldCreateInstance(CarbonInterface $date): bool
5657
{
5758
$daysOfMonth = $this->days_of_month ?? [$date->day];
5859
$monthDiff = ($date->month - $this->start_month + 12) % $this::getFrequency();
5960

6061
return in_array($date->day, $daysOfMonth) && $monthDiff === 0;
6162
}
6263

63-
public function shouldCreateRecurringInstance(Schedule $schedule, \Carbon\CarbonInterface $date): bool
64+
public function shouldCreateRecurringInstance(Schedule $schedule, CarbonInterface $date): bool
6465
{
6566
$daysOfMonth = $this->days_of_month ?? [$schedule->start_date->day];
6667
$monthDiff = ($date->month - $this->start_month + 12) % $this::getFrequency();

src/Data/WeeklyEvenOddFrequencyConfig/AbstractWeeklyOddEvenFrequencyConfig.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Zap\Data\WeeklyEvenOddFrequencyConfig;
44

5+
use Carbon\CarbonInterface;
56
use Zap\Data\FrequencyConfig;
67
use Zap\Helper\DateHelper;
78
use Zap\Models\Schedule;
@@ -15,27 +16,27 @@ public function __construct(
1516
public array $days = []
1617
) {}
1718

18-
abstract protected function isWeekTypeMatch(\Carbon\CarbonInterface $date): bool;
19+
abstract protected function isWeekTypeMatch(CarbonInterface $date): bool;
1920

20-
public function shouldCreateInstance(\Carbon\CarbonInterface $date): bool
21+
public function shouldCreateInstance(CarbonInterface $date): bool
2122
{
2223
return empty($this->days) || in_array(strtolower($date->format('l')), $this->days);
2324
}
2425

25-
public function shouldCreateRecurringInstance(Schedule $schedule, \Carbon\CarbonInterface $date): bool
26+
public function shouldCreateRecurringInstance(Schedule $schedule, CarbonInterface $date): bool
2627
{
2728
$allowedDays = ! empty($this->days) ? $this->days : ['monday'];
2829
$allowedDayNumbers = DateHelper::getDayNumbers($allowedDays);
2930

3031
return $this->isWeekTypeMatch($date) && in_array($date->dayOfWeek, $allowedDayNumbers);
3132
}
3233

33-
public function getNextRecurrence(\Carbon\CarbonInterface $current): \Carbon\CarbonInterface
34+
public function getNextRecurrence(CarbonInterface $current): CarbonInterface
3435
{
3536
return $this->getNextWeeklyOccurrence($current, $this->days);
3637
}
3738

38-
protected function getNextWeeklyOccurrence(\Carbon\CarbonInterface $current, array $allowedDays): \Carbon\CarbonInterface
39+
protected function getNextWeeklyOccurrence(CarbonInterface $current, array $allowedDays): CarbonInterface
3940
{
4041
$next = $current->copy()->addDay();
4142
$allowedDayNumbers = DateHelper::getDayNumbers($allowedDays);

src/Data/WeeklyEvenOddFrequencyConfig/WeeklyEvenFrequencyConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Zap\Data\WeeklyEvenOddFrequencyConfig;
44

5+
use Carbon\CarbonInterface;
56
use Zap\Helper\DateHelper;
67

78
/**
@@ -20,7 +21,7 @@ public static function fromArray(array $data): self
2021
);
2122
}
2223

23-
protected function isWeekTypeMatch(\Carbon\CarbonInterface $date): bool
24+
protected function isWeekTypeMatch(CarbonInterface $date): bool
2425
{
2526
return DateHelper::isDateInEvenIsoWeek($date);
2627
}

src/Data/WeeklyEvenOddFrequencyConfig/WeeklyOddFrequencyConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Zap\Data\WeeklyEvenOddFrequencyConfig;
44

5+
use Carbon\CarbonInterface;
56
use Zap\Helper\DateHelper;
67

78
/**
@@ -20,7 +21,7 @@ public static function fromArray(array $data): self
2021
);
2122
}
2223

23-
protected function isWeekTypeMatch(\Carbon\CarbonInterface $date): bool
24+
protected function isWeekTypeMatch(CarbonInterface $date): bool
2425
{
2526
return DateHelper::isDateInOddIsoWeek($date);
2627
}

src/Data/WeeklyFrequencyConfig/AbstractWeeklyFrequencyConfig.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function setStartFromStartDate(CarbonInterface $startDate): self
5858
return $this;
5959
}
6060

61-
public function shouldCreateInstance(\Carbon\CarbonInterface $date): bool
61+
public function shouldCreateInstance(CarbonInterface $date): bool
6262
{
6363
$dayMatches = empty($this->days) || in_array(strtolower($date->format('l')), $this->days);
6464

@@ -69,7 +69,7 @@ public function shouldCreateInstance(\Carbon\CarbonInterface $date): bool
6969
return $dayMatches && $this->startsOn->diffInWeeks($date) % static::getFrequency() === 0;
7070
}
7171

72-
public function shouldCreateRecurringInstance(Schedule $schedule, \Carbon\CarbonInterface $date): bool
72+
public function shouldCreateRecurringInstance(Schedule $schedule, CarbonInterface $date): bool
7373
{
7474
if ($this->startsOn === null) {
7575
$this->setStartFromStartDate($schedule->start_date);
@@ -93,12 +93,12 @@ public function shouldCreateRecurringInstance(Schedule $schedule, \Carbon\Carbon
9393
$this->startsOn->diffInWeeks($date) % static::getFrequency() === 0;
9494
}
9595

96-
public function getNextRecurrence(\Carbon\CarbonInterface $current): \Carbon\CarbonInterface
96+
public function getNextRecurrence(CarbonInterface $current): CarbonInterface
9797
{
9898
return $this->getNextBiWeeklyOccurrence($current, $this->days);
9999
}
100100

101-
protected function getNextBiWeeklyOccurrence(\Carbon\CarbonInterface $current, array $allowedDays): \Carbon\CarbonInterface
101+
protected function getNextBiWeeklyOccurrence(CarbonInterface $current, array $allowedDays): CarbonInterface
102102
{
103103
$next = $current->copy()->addDay();
104104
$weekStart = config()->integer('zap.calendar.week_start', CarbonInterface::MONDAY);

src/Enums/Frequency.php

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33
namespace Zap\Enums;
44

55
use Carbon\CarbonInterface;
6+
use Zap\Data\DailyFrequencyConfig;
67
use Zap\Data\FrequencyConfig;
8+
use Zap\Data\MonthlyFrequencyConfig\AnnuallyFrequencyConfig;
9+
use Zap\Data\MonthlyFrequencyConfig\BiMonthlyFrequencyConfig;
10+
use Zap\Data\MonthlyFrequencyConfig\MonthlyFrequencyConfig;
11+
use Zap\Data\MonthlyFrequencyConfig\QuarterlyFrequencyConfig;
12+
use Zap\Data\MonthlyFrequencyConfig\SemiAnnuallyFrequencyConfig;
13+
use Zap\Data\WeeklyEvenOddFrequencyConfig\WeeklyEvenFrequencyConfig;
14+
use Zap\Data\WeeklyEvenOddFrequencyConfig\WeeklyOddFrequencyConfig;
15+
use Zap\Data\WeeklyFrequencyConfig\BiWeeklyFrequencyConfig;
16+
use Zap\Data\WeeklyFrequencyConfig\WeeklyFrequencyConfig;
17+
use Zap\Helper\DateHelper;
718

819
enum Frequency: string
920
{
@@ -23,8 +34,8 @@ public function getNextRecurrence(CarbonInterface $current): CarbonInterface
2334
return match ($this) {
2435
self::DAILY => $current->copy()->addDay(),
2536
self::WEEKLY => $current->copy()->addWeek(),
26-
self::WEEKLY_ODD => \Zap\Helper\DateHelper::nextWeekOdd($current),
27-
self::WEEKLY_EVEN => \Zap\Helper\DateHelper::nextWeekEven($current),
37+
self::WEEKLY_ODD => DateHelper::nextWeekOdd($current),
38+
self::WEEKLY_EVEN => DateHelper::nextWeekEven($current),
2839
self::BIWEEKLY => $current->copy()->addWeeks(2),
2940
self::MONTHLY => $current->copy()->addMonth(),
3041
self::BIMONTHLY => $current->copy()->addMonths(2),
@@ -40,16 +51,16 @@ public function getNextRecurrence(CarbonInterface $current): CarbonInterface
4051
public function configClass(): string
4152
{
4253
return match ($this) {
43-
self::DAILY => \Zap\Data\DailyFrequencyConfig::class,
44-
self::WEEKLY => \Zap\Data\WeeklyFrequencyConfig\WeeklyFrequencyConfig::class,
45-
self::WEEKLY_ODD => \Zap\Data\WeeklyEvenOddFrequencyConfig\WeeklyOddFrequencyConfig::class,
46-
self::WEEKLY_EVEN => \Zap\Data\WeeklyEvenOddFrequencyConfig\WeeklyEvenFrequencyConfig::class,
47-
self::BIWEEKLY => \Zap\Data\WeeklyFrequencyConfig\BiWeeklyFrequencyConfig::class,
48-
self::MONTHLY => \Zap\Data\MonthlyFrequencyConfig\MonthlyFrequencyConfig::class,
49-
self::BIMONTHLY => \Zap\Data\MonthlyFrequencyConfig\BiMonthlyFrequencyConfig::class,
50-
self::QUARTERLY => \Zap\Data\MonthlyFrequencyConfig\QuarterlyFrequencyConfig::class,
51-
self::SEMIANNUALLY => \Zap\Data\MonthlyFrequencyConfig\SemiAnnuallyFrequencyConfig::class,
52-
self::ANNUALLY => \Zap\Data\MonthlyFrequencyConfig\AnnuallyFrequencyConfig::class,
54+
self::DAILY => DailyFrequencyConfig::class,
55+
self::WEEKLY => WeeklyFrequencyConfig::class,
56+
self::WEEKLY_ODD => WeeklyOddFrequencyConfig::class,
57+
self::WEEKLY_EVEN => WeeklyEvenFrequencyConfig::class,
58+
self::BIWEEKLY => BiWeeklyFrequencyConfig::class,
59+
self::MONTHLY => MonthlyFrequencyConfig::class,
60+
self::BIMONTHLY => BiMonthlyFrequencyConfig::class,
61+
self::QUARTERLY => QuarterlyFrequencyConfig::class,
62+
self::SEMIANNUALLY => SemiAnnuallyFrequencyConfig::class,
63+
self::ANNUALLY => AnnuallyFrequencyConfig::class,
5364
};
5465
}
5566

src/Facades/Zap.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
use Illuminate\Support\Facades\Facade;
66
use Zap\Builders\ScheduleBuilder;
7+
use Zap\Services\ScheduleService;
78

89
/**
910
* @method static ScheduleBuilder for(mixed $schedulable)
1011
* @method static ScheduleBuilder schedule()
1112
* @method static array findConflicts(\Zap\Models\Schedule $schedule)
1213
* @method static bool hasConflicts(\Zap\Models\Schedule $schedule)
1314
*
14-
* @see \Zap\Services\ScheduleService
15+
* @see ScheduleService
1516
*/
1617
class Zap extends Facade
1718
{

0 commit comments

Comments
 (0)