Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
70.00% covered (warning)
70.00%
7 / 10
87.50% covered (warning)
87.50%
7 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 1
DownloadFileRouteDefinition
70.00% covered (warning)
70.00%
7 / 10
87.50% covered (warning)
87.50%
7 / 8
11.19
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getController
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUrlPrefixes
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getOperationId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMethod
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUrl
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAction
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createFrom
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2namespace Apie\Graphql\RouteDefinitions;
3
4use Apie\Common\ActionDefinitions\ActionDefinitionInterface;
5use Apie\Common\ActionDefinitions\DownloadFilesActionDefinition;
6use Apie\Common\Actions\StreamItemMethodAction;
7use Apie\Common\Enums\UrlPrefix;
8use Apie\Common\Lists\UrlPrefixList;
9use Apie\Common\RouteDefinitions\AbstractRestApiRouteDefinition;
10use Apie\Core\BoundedContext\BoundedContextId;
11use Apie\Core\Enums\RequestMethod;
12use Apie\Core\ValueObjects\UrlRouteDefinition;
13use Apie\Graphql\Controllers\DownloadFileController;
14use ReflectionClass;
15
16class DownloadFileRouteDefinition extends AbstractRestApiRouteDefinition
17{
18    /**
19     * @param ReflectionClass<EntityInterface> $className
20     */
21    public function __construct(ReflectionClass $className, BoundedContextId $boundedContextId)
22    {
23        parent::__construct($className, $boundedContextId);
24    }
25
26    public function getController(): string
27    {
28        return DownloadFileController::class;
29    }
30
31    public function getUrlPrefixes(): UrlPrefixList
32    {
33        return new UrlPrefixList([UrlPrefix::GRAPHQL]);
34    }
35
36    public function getOperationId(): string
37    {
38        return 'stream-graphql-' . $this->class->getShortName() . '-run-download';
39    }
40    
41    public function getMethod(): RequestMethod
42    {
43        return RequestMethod::GET;
44    }
45
46    public function getUrl(): UrlRouteDefinition
47    {
48        return new UrlRouteDefinition('/' . $this->class->getShortName() . '/{id}/download/{properties}');
49    }
50
51    public function getAction(): string
52    {
53        return StreamItemMethodAction::class;
54    }
55
56    public static function createFrom(ActionDefinitionInterface $actionDefinition): ?AbstractRestApiRouteDefinition
57    {
58        if ($actionDefinition instanceof DownloadFilesActionDefinition) {
59            return new self($actionDefinition->getResourceName(), $actionDefinition->getBoundedContextId());
60        }
61        return null;
62    }
63}