Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| BadgeStatusTransformer | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
| supports | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| transformRead | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| transformWrite | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Core\Engine\Application\Transformer; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | use App\Core\Engine\Domain\Model\FieldMetadata; |
| 12 | |
| 13 | /** |
| 14 | * Status Badge UiType Transformer. |
| 15 | * |
| 16 | * Handles UiType: badge_status. |
| 17 | * Read: normalizes status value string for presentation layer formatting. |
| 18 | * Write: returns the raw value unchanged (field is readonly in DB). |
| 19 | * |
| 20 | * @package App\Core\Engine\Application\Transformer |
| 21 | */ |
| 22 | final class BadgeStatusTransformer implements UiTypeTransformerInterface |
| 23 | { |
| 24 | /** {@inheritdoc} */ |
| 25 | public function supports(string $uitypeName): bool |
| 26 | { |
| 27 | return $uitypeName === 'badge_status'; |
| 28 | } |
| 29 | |
| 30 | /** {@inheritdoc} */ |
| 31 | public function transformRead(mixed $rawValue, FieldMetadata $field): string |
| 32 | { |
| 33 | if ($rawValue === null) { |
| 34 | return ''; |
| 35 | } |
| 36 | |
| 37 | return (string) $rawValue; |
| 38 | } |
| 39 | |
| 40 | /** {@inheritdoc} */ |
| 41 | public function transformWrite(mixed $inputValue, FieldMetadata $field): mixed |
| 42 | { |
| 43 | return $inputValue; |
| 44 | } |
| 45 | } |