Passed
Push — 37_api_medialibrary_get_api_me... ( 4d80e2 )
by
unknown
120:07 queued 108:23
created

AssetController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 21
ccs 4
cts 7
cp 0.5714
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAssetAction() 0 4 1
A __construct() 0 4 1
1
<?php
2
3
namespace Backend\Modules\MediaLibrary\Api;
4
5
use Backend\Modules\MediaLibrary\Domain\MediaItem\MediaItemRepository;
6
use FOS\RestBundle\Controller\Annotations as Rest;
7
use Symfony\Component\HttpFoundation\JsonResponse;
8
use Symfony\Component\Serializer\SerializerInterface;
9
10
final class AssetController
11
{
12
    /** @var MediaItemRepository */
13
    private $mediaItemRepository;
14
15
    /** @var SerializerInterface */
16
    private $serializer;
17
18 1
    public function __construct(MediaItemRepository $mediaItemRepository, SerializerInterface $serializer)
19
    {
20 1
        $this->mediaItemRepository = $mediaItemRepository;
21 1
        $this->serializer = $serializer;
22 1
    }
23
24
    /**
25
     * @Rest\Get("/medialibrary/asset/{uuid}")
26
     */
27
    public function getAssetAction(string $uuid): JsonResponse
28
    {
29
        return JsonResponse::fromJsonString(
30
            $this->serializer->serialize($this->mediaItemRepository->find($uuid), 'json')
31
        );
32
    }
33
}
34