Completed
Push — master ( 0be8e1...585ca2 )
by Daniel
59:26 queued 46:02
created

FileTrait::setFilePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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