Completed
Push — develop ( f05cec...11f198 )
by Daniel
07:33
created

FileTrait::setFileData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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