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
AllowsHandler
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
5
100.00% covered (success)
100.00%
1 / 1
 apply
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
4
 properties
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Field\Schema;
6
7use Cosray\Exception\RuntimeException;
8use Cosray\Field\Blocks;
9use Cosray\Field\Entries;
10use Cosray\Field\Field;
11use Cosray\Schema\Allows;
12
13class AllowsHandler extends Handler
14{
15    public function apply(object $meta, Field $field): void
16    {
17        if (($field instanceof Entries || $field instanceof Blocks) && $meta instanceof Allows) {
18            $field->allow(...$meta->types);
19
20            return;
21        }
22
23        throw new RuntimeException($this->capabilityErrorMessage($field, Entries::class));
24    }
25
26    public function properties(object $meta, Field $field): array
27    {
28        return [];
29    }
30}