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