Passed
Push — develop ( a2aeae...9ee07e )
by Daniel
05:41
created

FileTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 40
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilePath() 0 3 1
A setFilePath() 0 3 1
A getImagineFilters() 0 6 1
A getDir() 0 3 1
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
     * @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
            'thumbnail' => 'thumbnail',
45
            'placeholderSquare' => 'placeholder_square',
46
            'placeholder' => 'placeholder'
47
        ];
48
    }
49
50
    public function getDir(): ?string
51
    {
52
        return null;
53
    }
54
}
55