Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
TypesHandler
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 resolve
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Collection\Schema;
6
7use Cosray\Exception\RuntimeException;
8use Cosray\Schema\Types;
9use Override;
10
11class TypesHandler extends Handler
12{
13    #[Override]
14    public function resolve(object $meta, string $class): array
15    {
16        assert($meta instanceof Types, 'The registry maps #[Types] to this handler');
17
18        $types = array_map(trim(...), $meta->types);
19
20        if ($types === [] || in_array('', $types, true)) {
21            throw new RuntimeException("#[Types] of collection '{$class}' must name at least one node type");
22        }
23
24        return ['types' => $types];
25    }
26}