Test Failed
Push — develop ( b13210...c32797 )
by Daniel
04:26
created

FileTrait::setFilePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Component;
4
5
use ApiPlatform\Core\Annotation\ApiProperty;
6
use Doctrine\ORM\Mapping as ORM;
7
use Silverback\ApiComponentBundle\File\FileData;
8
use Symfony\Component\Serializer\Annotation\Groups;
9
10
/**
11
 * Trait FileTrait
12
 * @package Silverback\ApiComponentBundle\Entity\Component
13
 */
14
trait FileTrait
15
{
16
    /**
17
     * We are not asserting this is a file here because it may be a string for dynamic component e.g. {{ filePath }}
18
     * validation constraint could be made perhaps to validate a file or a variable
19
     * @ORM\Column(type="string", nullable=false)
20
     * @Groups({"component", "content"})
21
     * @ApiProperty(iri="http://schema.org/contentUrl")
22
     * @var null|string
23
     */
24
    protected $filePath;
25
26
    /**
27
     * @Groups({"component", "content"})
28
     * @var FileData|null
29
     */
30
    private $fileData;
31
32
    /**
33
     * @return null|string
34
     */
35
    public function getFilePath(): ?string
36
    {
37
        return $this->filePath;
38
    }
39
40
    /**
41
     * @param null|string $filePath
42
     */
43
    public function setFilePath(?string $filePath): void
44
    {
45
        $this->filePath = $filePath;
46
    }
47
48
    public static function getImagineFilters(): array
49
    {
50
        return [
51
            'thumbnail' => 'thumbnail',
52
            'placeholderSquare' => 'placeholder_square',
53
            'placeholder' => 'placeholder'
54
        ];
55
    }
56
57
    public function getDir(): ?string
58
    {
59
        return null;
60
    }
61
62
    /**
63
     * @return null|FileData
64
     */
65
    public function getFileData(): ?FileData
66
    {
67
        return $this->fileData;
68
    }
69
70
    /**
71
     * @param null|FileData $fileData
72
     */
73
    public function setFileData(?FileData $fileData): void
74
    {
75
        $this->fileData = $fileData;
76
    }
77
}
78