Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| AllowsHandler | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
5 | |
100.00% |
1 / 1 |
| apply | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
4 | |||
| properties | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Field\Schema; |
| 6 | |
| 7 | use Cosray\Exception\RuntimeException; |
| 8 | use Cosray\Field\Blocks; |
| 9 | use Cosray\Field\Entries; |
| 10 | use Cosray\Field\Field; |
| 11 | use Cosray\Schema\Allows; |
| 12 | |
| 13 | class 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 | } |