Completed
Push — master ( d7020d...a4700d )
by Daniel
06:50
created

FileDataTransformer::transform()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Silverback\ApiComponentBundle\DataTransformer;
4
5
use Silverback\ApiComponentBundle\Entity\Component\FileInterface;
6
use Silverback\ApiComponentBundle\Factory\FileDataFactory;
7
8
final class FileDataTransformer extends AbstractDataTransformer
9
{
10
    /**
11
     * @param FileInterface $object
12
     */
13
    public function transform($object, array $context = []): FileInterface
14
    {
15
        /** @var FileDataFactory $factory */
16
        $factory = $this->container->get(FileDataFactory::class);
17
        $fileData = $factory->create($object);
18
        $object->setFileData($fileData);
19
        return $object;
20
    }
21
22
    public function supportsTransformation($data, array $context = []): bool
23
    {
24
        return $data instanceof FileInterface;
25
    }
26
27
    public static function getSubscribedServices(): array
28
    {
29
        return [
30
            '?' . FileDataFactory::class
31
        ];
32
    }
33
}
34