ldc-cocotte/domain/Models/ValueObjects/IcsContent.php

27 lines
648 B
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects;
use Webmozart\Assert\Assert;
final readonly class IcsContent implements \Stringable
{
public function __construct(
public string $value,
) {
$trimmed = trim($value);
Assert::stringNotEmpty($trimmed, 'ICS content cannot be empty.');
Assert::startsWith($trimmed, 'BEGIN:VCALENDAR', 'ICS content must start with BEGIN:VCALENDAR.');
Assert::endsWith($trimmed, 'END:VCALENDAR', 'ICS content must end with END:VCALENDAR.');
}
#[\Override]
public function __toString(): string
{
return $this->value;
}
}