Passed
Push — master ( 6d474d...b26602 )
by Daniel
11:50
created

FileTrait::getImagineFilters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 9.4285
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", "route"})
20
     * @ApiProperty(iri="http://schema.org/contentUrl")
21
     * @var null|string
22
     */
23
    protected $filePath;
24
25
    /**
26
     * @return null|string
27
     */
28 6
    public function getFilePath(): ?string
29
    {
30 6
        return $this->filePath;
31
    }
32
33
    /**
34
     * @param null|string $filePath
35
     */
36 4
    public function setFilePath(?string $filePath): void
37
    {
38 4
        $this->filePath = $filePath;
39 4
    }
40
41 1
    public static function getImagineFilters(): array
42
    {
43
        return [
44 1
            'thumbnailPath' => 'thumbnail',
45
            'placeholderPath' => 'placeholder_square'
46
        ];
47
    }
48
}
49