Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
AllowsHandler
80.00% covered (warning)
80.00%
4 / 5
50.00% covered (danger)
50.00%
1 / 2
4.13
0.00% covered (danger)
0.00%
0 / 1
 apply
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 properties
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Field\Schema;
6
7use Cosray\Exception\RuntimeException;
8use Cosray\Field\Entries;
9use Cosray\Field\Field;
10use Cosray\Schema\Allows;
11
12class AllowsHandler extends Handler
13{
14    public function apply(object $meta, Field $field): void
15    {
16        if ($field instanceof Entries && $meta instanceof Allows) {
17            $field->allow(...$meta->types);
18
19            return;
20        }
21
22        throw new RuntimeException($this->capabilityErrorMessage($field, Entries::class));
23    }
24
25    public function properties(object $meta, Field $field): array
26    {
27        return [];
28    }
29}