ScheduleTimeSlotService
in package
A class service for working with the logic business of schedule time slots.
Tags
Table of Contents
- $scheduleTimeSlotRepository : ScheduleTimeSlotRepository
- __construct() : mixed
- ScheduleTimeSlotService constructor.
- countAppointments() : int
- Count the number of appointments for a schedule time slot.
- delete() : void
- Delete a schedule time slot by id.
- findById() : ScheduleTimeSlotDomain
- Find a schedule time slot by id.
- findByScheduleId() : array<string|int, ScheduleTimeSlotDomain>
- Find all schedule time slots for a schedule.
- saveTimeSlots() : void
- Save the schedule time slots.
- validateTimeSlots() : void
- Apply business validations to the schedule time slots. If the time slots overlap, an exception is thrown.
- checkOverlap() : bool
- Validate if two time slots overlap.
- checkOverlaps() : void
- Check if the time slots for a day overlap. If the time slots overlap, an exception is thrown.
- mapScheduleTimeSlotEntityToDomain() : ScheduleTimeSlotDomain
- Map a schedule time slot entity to a domain object.
Properties
$scheduleTimeSlotRepository
private
ScheduleTimeSlotRepository
$scheduleTimeSlotRepository
The schedule time slot repository.
Methods
__construct()
ScheduleTimeSlotService constructor.
public
__construct(ScheduleTimeSlotRepository $scheduleTimeSlotRepository) : mixed
Parameters
- $scheduleTimeSlotRepository : ScheduleTimeSlotRepository
-
The schedule time slot repository.
Return values
mixed —countAppointments()
Count the number of appointments for a schedule time slot.
public
countAppointments(int $id) : int
Parameters
- $id : int
-
The id of the schedule time slot.
Tags
Return values
int —delete()
Delete a schedule time slot by id.
public
delete(int $id) : void
Parameters
- $id : int
-
The id of the schedule time slot to delete.
Tags
Return values
void —findById()
Find a schedule time slot by id.
public
findById(int $id) : ScheduleTimeSlotDomain
Parameters
- $id : int
-
The id of the schedule time slot to find.
Tags
Return values
ScheduleTimeSlotDomain —findByScheduleId()
Find all schedule time slots for a schedule.
public
findByScheduleId(int $scheduleId) : array<string|int, ScheduleTimeSlotDomain>
Parameters
- $scheduleId : int
-
The schedule id to find the schedule time slots.
Tags
Return values
array<string|int, ScheduleTimeSlotDomain> —An array of schedule time slot domain objects.
saveTimeSlots()
Save the schedule time slots.
public
saveTimeSlots(int $scheduleId, array<string|int, ScheduleTimeSlotDomain> $timeSlots) : void
Parameters
- $scheduleId : int
-
The schedule id.
- $timeSlots : array<string|int, ScheduleTimeSlotDomain>
-
The schedule time slots to save.
Tags
Return values
void —validateTimeSlots()
Apply business validations to the schedule time slots. If the time slots overlap, an exception is thrown.
public
validateTimeSlots(array<string|int, ScheduleTimeSlotDomain> $scheduleTimeSlots) : void
Parameters
- $scheduleTimeSlots : array<string|int, ScheduleTimeSlotDomain>
-
The schedule time slots to validate.
Tags
Return values
void —checkOverlap()
Validate if two time slots overlap.
private
checkOverlap(ScheduleTimeSlotDomain $timeSlot1, ScheduleTimeSlotDomain $timeSlot2) : bool
Parameters
- $timeSlot1 : ScheduleTimeSlotDomain
-
The first time slot.
- $timeSlot2 : ScheduleTimeSlotDomain
-
The second time slot.
Return values
bool —True if the time slots overlap, false otherwise.
checkOverlaps()
Check if the time slots for a day overlap. If the time slots overlap, an exception is thrown.
private
checkOverlaps(array<string|int, mixed> $timeSlots) : void
Parameters
- $timeSlots : array<string|int, mixed>
Tags
Return values
void —mapScheduleTimeSlotEntityToDomain()
Map a schedule time slot entity to a domain object.
private
mapScheduleTimeSlotEntityToDomain(ScheduleTimeSlotEntity $scheduleTimeSlotEntity) : ScheduleTimeSlotDomain
Parameters
- $scheduleTimeSlotEntity : ScheduleTimeSlotEntity
-
The schedule time slot entity to map.