Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Title
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 getExceptionClass
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 validateRules
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10namespace AppDemo\Library\Domain;
11
12use AppDemo\Library\Domain\Exception\InvalidTitleException;
13use Assert\Assert;
14use Override;
15use Phexium\Domain\AbstractStringValueObject;
16use Phexium\Domain\ValueObjectInterface;
17
18final readonly class Title extends AbstractStringValueObject implements ValueObjectInterface
19{
20    #[Override]
21    protected static function getExceptionClass(): callable
22    {
23        return InvalidTitleException::whenValidationFailed(...);
24    }
25
26    #[Override]
27    protected function validateRules(string $value): void
28    {
29        Assert::that($value)
30            ->notEmpty('Title cannot be empty')
31            ->maxLength(200, 'Title cannot exceed 200 characters')
32        ;
33    }
34}