27 lines
695 B
PHP
27 lines
695 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Exception;
|
|
|
|
use App\Entity\Booking;
|
|
|
|
/**
|
|
* One person may not hold two resources of the same kind at overlapping times. A desk in the
|
|
* morning and a different one in the afternoon is fine -- only the overlap is refused.
|
|
*/
|
|
final class AlreadyHoldingResourceException extends \RuntimeException
|
|
{
|
|
public function __construct(public readonly Booking $existing)
|
|
{
|
|
$time = $existing->getTimeRange();
|
|
|
|
parent::__construct(\sprintf(
|
|
'Du hast am %s bereits %s gebucht (%s).',
|
|
$existing->getDate()->format('d.m.Y'),
|
|
$existing->getResource()->getLabel(),
|
|
$time,
|
|
));
|
|
}
|
|
}
|