Lines
0.00%
0 / 8
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ExposedStateFields | 0.00% | 0 / 8 | 0.00% | 0 / 1 | 20 | 0.00% | 0 / 1 | |||
| formatStateChange | 0.00% | 0 / 8 | 0.00% | 0 / 1 | 20 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Client\Component; | |
| 6 | ||
| 7 | use Stewart\Contracts\Exposure\ExposedStateChange; | |
| 8 | ||
| 9 | final class ExposedStateFields | |
| 10 | { | |
| 11 | /** @return array<string, mixed> */ | |
| 12 | public static function formatStateChange(ExposedStateChange $change): array | |
| 13 | { | |
| 14 | $fields = []; | |
| 15 | ||
| 16 | if ($change->state !== null) { | |
| 17 | $fields['state'] = $change->state->value; | |
| 18 | } | |
| 19 | ||
| 20 | if ($change->attributes !== null) { | |
| 21 | $fields['attributes'] = $change->attributes; | |
| 22 | } | |
| 23 | ||
| 24 | if ($change->available !== null) { | |
| 25 | $fields['available'] = $change->available; | |
| 26 | } | |
| 27 | ||
| 28 | return $fields; | |
| 29 | } | |
| 30 | } |