Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | namespace Apie\Core\Actions; |
| 3 | |
| 4 | use Apie\Core\Context\ApieContext; |
| 5 | use Apie\Core\Dto\ListOf; |
| 6 | use Apie\Core\Entities\EntityInterface; |
| 7 | use Apie\Core\Lists\StringList; |
| 8 | use ReflectionClass; |
| 9 | use ReflectionMethod; |
| 10 | use ReflectionType; |
| 11 | |
| 12 | /** |
| 13 | * Common interface for actions. Actions are the parts that actually do something in Apie and are used internally by high-level |
| 14 | * functionality, for example all Rest API calls use actions internally. |
| 15 | */ |
| 16 | interface ActionInterface |
| 17 | { |
| 18 | public function __construct(ApieFacadeInterface $apieFacade); |
| 19 | /** |
| 20 | * @param array<string|int, mixed> $rawContents |
| 21 | */ |
| 22 | public function __invoke(ApieContext $context, array $rawContents): ActionResponse; |
| 23 | |
| 24 | /** |
| 25 | * Returns true if this action is allowed in this context. |
| 26 | */ |
| 27 | public static function isAuthorized(ApieContext $context, bool $runtimeChecks, bool $throwError = false): bool; |
| 28 | |
| 29 | /** |
| 30 | * Gets input type of action, for example it should create the object on POST or do a method call. |
| 31 | * |
| 32 | * @template T of EntityInterface |
| 33 | * @param ReflectionClass<T> $class |
| 34 | * @return ReflectionClass<T>|ReflectionMethod|ReflectionType |
| 35 | */ |
| 36 | public static function getInputType(ReflectionClass $class): ReflectionClass|ReflectionMethod|ReflectionType; |
| 37 | |
| 38 | /** |
| 39 | * Returns output type of response, for example the resource being updated or the result of the method call. |
| 40 | * |
| 41 | * @template T of EntityInterface |
| 42 | * @param ReflectionClass<T> $class |
| 43 | * @return ReflectionClass<T>|ReflectionMethod|ReflectionType|ListOf |
| 44 | */ |
| 45 | public static function getOutputType(ReflectionClass $class): ReflectionClass|ReflectionMethod|ReflectionType|ListOf; |
| 46 | |
| 47 | /** |
| 48 | * Returns possible response statuses. For example a DELETE can only be an error or an empty response. |
| 49 | */ |
| 50 | public static function getPossibleActionResponseStatuses(): ActionResponseStatusList; |
| 51 | |
| 52 | /** |
| 53 | * Returns description of action. |
| 54 | * |
| 55 | * @param ReflectionClass<EntityInterface> $class |
| 56 | */ |
| 57 | public static function getDescription(ReflectionClass $class): string; |
| 58 | |
| 59 | /** |
| 60 | * Returns tags of an action so a tool can combine these. |
| 61 | * |
| 62 | * @param ReflectionClass<EntityInterface> $class |
| 63 | */ |
| 64 | public static function getTags(ReflectionClass $class): StringList; |
| 65 | |
| 66 | /** |
| 67 | * @param ReflectionClass<EntityInterface> $class |
| 68 | * @return array<string, mixed> |
| 69 | */ |
| 70 | public static function getRouteAttributes(ReflectionClass $class): array; |
| 71 | } |