Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ActionDefinitionProvider | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
provideActionDefinitions | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | namespace Apie\Common; |
3 | |
4 | use Apie\Common\ActionDefinitions\ActionDefinitionInterface; |
5 | use Apie\Common\ActionDefinitions\CreateResourceActionDefinition; |
6 | use Apie\Common\ActionDefinitions\DownloadFilesActionDefinition; |
7 | use Apie\Common\ActionDefinitions\GetResourceActionDefinition; |
8 | use Apie\Common\ActionDefinitions\GetResourceListActionDefinition; |
9 | use Apie\Common\ActionDefinitions\ModifyResourceActionDefinition; |
10 | use Apie\Common\ActionDefinitions\RemoveResourceActionDefinition; |
11 | use Apie\Common\ActionDefinitions\ReplaceResourceActionDefinition; |
12 | use Apie\Common\ActionDefinitions\RunGlobalMethodDefinition; |
13 | use Apie\Common\ActionDefinitions\RunResourceMethodDefinition; |
14 | use Apie\Common\Lists\ActionDefinitionList; |
15 | use Apie\Core\BoundedContext\BoundedContext; |
16 | use Apie\Core\Context\ApieContext; |
17 | |
18 | class ActionDefinitionProvider |
19 | { |
20 | /** |
21 | * @var array<int, class-string<ActionDefinitionInterface>> |
22 | */ |
23 | private const ACTION_DEFINITION_CLASSES = [ |
24 | CreateResourceActionDefinition::class, |
25 | ReplaceResourceActionDefinition::class, |
26 | GetResourceActionDefinition::class, |
27 | GetResourceListActionDefinition::class, |
28 | ModifyResourceActionDefinition::class, |
29 | RemoveResourceActionDefinition::class, |
30 | RunGlobalMethodDefinition::class, |
31 | RunResourceMethodDefinition::class, |
32 | DownloadFilesActionDefinition::class, |
33 | ]; |
34 | |
35 | public function provideActionDefinitions(BoundedContext $boundedContext, ApieContext $apieContext, bool $runtimeChecks = false): ActionDefinitionList |
36 | { |
37 | $actionDefinitions = []; |
38 | foreach (self::ACTION_DEFINITION_CLASSES as $actionDefinitionClass) { |
39 | foreach ($actionDefinitionClass::provideActionDefinitions($boundedContext, $apieContext, $runtimeChecks) as $actionDefinition) { |
40 | $actionDefinitions[] = $actionDefinition; |
41 | } |
42 | } |
43 | |
44 | return new ActionDefinitionList($actionDefinitions); |
45 | } |
46 | } |