Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
TitleHandler
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 resolve
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Node\Schema;
6
7use Cosray\Exception\RuntimeException;
8use Cosray\Schema\Title;
9use Override;
10
11class TitleHandler extends Handler
12{
13    #[Override]
14    public function resolve(object $meta, string $nodeClass): array
15    {
16        assert($meta instanceof Title, 'The registry maps #[Title] to this handler');
17
18        if ($meta->field === '') {
19            throw new RuntimeException(
20                "The #[Title] attribute on node '{$nodeClass}' requires a non-empty field name when used on a class.",
21            );
22        }
23
24        return ['titleField' => $meta->field];
25    }
26}