Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ActionDefinitionProvider
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 provideActionDefinitions
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2namespace Apie\Common;
3
4use Apie\Common\ActionDefinitions\ActionDefinitionInterface;
5use Apie\Common\ActionDefinitions\CreateResourceActionDefinition;
6use Apie\Common\ActionDefinitions\DownloadFilesActionDefinition;
7use Apie\Common\ActionDefinitions\GetResourceActionDefinition;
8use Apie\Common\ActionDefinitions\GetResourceListActionDefinition;
9use Apie\Common\ActionDefinitions\ModifyResourceActionDefinition;
10use Apie\Common\ActionDefinitions\RemoveResourceActionDefinition;
11use Apie\Common\ActionDefinitions\ReplaceResourceActionDefinition;
12use Apie\Common\ActionDefinitions\RunGlobalMethodDefinition;
13use Apie\Common\ActionDefinitions\RunResourceMethodDefinition;
14use Apie\Common\Lists\ActionDefinitionList;
15use Apie\Core\BoundedContext\BoundedContext;
16use Apie\Core\Context\ApieContext;
17
18class 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}