feat: add booking time ranges and repeating series
This commit is contained in:
1 parent
59feca2f8e
commit
d433d271d0
29 files changed
+2135
-180
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Booking;
|
||||
|
||||
use App\Entity\Booking;
|
||||
use App\Entity\BookingSeries;
|
||||
|
||||
/**
|
||||
* What creating a series actually achieved. A series is materialised best-effort: days that were
|
||||
* already taken are skipped and reported, rather than failing the whole series.
|
||||
*/
|
||||
final readonly class SeriesResult
|
||||
{
|
||||
/**
|
||||
* @param list<Booking> $created
|
||||
* @param array<string, string> $skipped Y-m-d => reason
|
||||
*/
|
||||
public function __construct(
|
||||
public BookingSeries $series,
|
||||
public array $created,
|
||||
public array $skipped,
|
||||
) {
|
||||
}
|
||||
|
||||
public function createdCount(): int
|
||||
{
|
||||
return \count($this->created);
|
||||
}
|
||||
|
||||
public function skippedCount(): int
|
||||
{
|
||||
return \count($this->skipped);
|
||||
}
|
||||
|
||||
public function isCompletelyBlocked(): bool
|
||||
{
|
||||
return [] === $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function skippedDates(): array
|
||||
{
|
||||
return array_map(
|
||||
static fn (string $date): string => (new \DateTimeImmutable($date))->format('j.n.'),
|
||||
array_keys($this->skipped),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user