Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| TriggerCatalog | |
0.00% |
0 / 17 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
| listTriggers | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| eventClasses | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| keyForClass | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| classForKey | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| listActions | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| listOperators | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Automation\Application\Services; |
| 6 | |
| 7 | use ImovelZapAi\Automation\Domain\Enums\ActionKey; |
| 8 | use ImovelZapAi\Automation\Domain\Enums\ConditionOperator; |
| 9 | use ImovelZapAi\Automation\Domain\Enums\TriggerEventKey; |
| 10 | |
| 11 | final class TriggerCatalog |
| 12 | { |
| 13 | /** @return list<array{key: string, label: string, category: string, event_class: string}> */ |
| 14 | public function listTriggers(): array |
| 15 | { |
| 16 | return array_map(static fn (TriggerEventKey $key): array => [ |
| 17 | 'key' => $key->value, |
| 18 | 'label' => $key->label(), |
| 19 | 'category' => $key->category(), |
| 20 | 'event_class' => $key->eventClass(), |
| 21 | ], TriggerEventKey::cases()); |
| 22 | } |
| 23 | |
| 24 | /** @return list<string> */ |
| 25 | public static function eventClasses(): array |
| 26 | { |
| 27 | return array_map(static fn (TriggerEventKey $key): string => $key->eventClass(), TriggerEventKey::cases()); |
| 28 | } |
| 29 | |
| 30 | public static function keyForClass(string $class): ?string |
| 31 | { |
| 32 | return TriggerEventKey::fromEventClass($class)?->value; |
| 33 | } |
| 34 | |
| 35 | public static function classForKey(string $key): ?string |
| 36 | { |
| 37 | return TriggerEventKey::fromKey($key)?->eventClass(); |
| 38 | } |
| 39 | |
| 40 | /** @return list<array{key: string, label: string}> */ |
| 41 | public function listActions(): array |
| 42 | { |
| 43 | return array_map(static fn (ActionKey $key): array => [ |
| 44 | 'key' => $key->value, |
| 45 | 'label' => $key->label(), |
| 46 | ], ActionKey::cases()); |
| 47 | } |
| 48 | |
| 49 | /** @return list<array{key: string, label: string}> */ |
| 50 | public function listOperators(): array |
| 51 | { |
| 52 | return array_map(static fn (ConditionOperator $op): array => [ |
| 53 | 'key' => $op->value, |
| 54 | 'label' => $op->label(), |
| 55 | ], ConditionOperator::cases()); |
| 56 | } |
| 57 | } |