Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
WhenHandler
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 apply
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 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\Field\Field;
8use Cosray\Schema\When;
9use Override;
10
11class WhenHandler extends Handler
12{
13    #[Override]
14    public function apply(object $meta, Field $field): void
15    {
16        // Activation happens at hydration time (FieldHydrator); the
17        // handler only carries the condition into the field payload.
18    }
19
20    #[Override]
21    public function properties(object $meta, Field $field): array
22    {
23        assert($meta instanceof When, 'The registry only routes When attributes to this handler');
24
25        return ['when' => $meta->condition()];
26    }
27}