Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| SubscriptionEventType | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| tryFromString | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
3 | |||
| notification | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace LambdaTwelve\OneRecord\Api; |
| 6 | |
| 7 | use LambdaTwelve\OneRecord\Vocabulary\Generated\Api; |
| 8 | |
| 9 | /** |
| 10 | * What a subscriber wants to hear about. Each maps to the notification it produces. |
| 11 | */ |
| 12 | enum SubscriptionEventType: string |
| 13 | { |
| 14 | case LogisticsObjectCreated = Api::LOGISTICS_OBJECT_CREATED; |
| 15 | case LogisticsObjectUpdated = Api::LOGISTICS_OBJECT_UPDATED; |
| 16 | case LogisticsEventReceived = Api::LOGISTICS_EVENT_RECEIVED; |
| 17 | |
| 18 | public static function tryFromString(string $value): ?self |
| 19 | { |
| 20 | $value = str_starts_with($value, 'api:') ? Api::NAMESPACE . substr($value, 4) : $value; |
| 21 | |
| 22 | return self::tryFrom(str_contains($value, ':') ? $value : Api::NAMESPACE . $value); |
| 23 | } |
| 24 | |
| 25 | public function notification(): NotificationEventType |
| 26 | { |
| 27 | return NotificationEventType::from($this->value); |
| 28 | } |
| 29 | } |