Completed
Pull Request — master (#175)
by Mikołaj
01:54 queued 15s
created

Media::getPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusCmsPlugin\Entity;
14
15
use Sylius\Component\Resource\Model\ToggleableTrait;
16
use Sylius\Component\Resource\Model\TranslatableTrait;
17
use Sylius\Component\Resource\Model\TranslationInterface;
18
use Symfony\Component\HttpFoundation\File\File;
19
20
class Media implements MediaInterface
21
{
22
    use ToggleableTrait;
23
    use SectionableTrait;
24
    use ProductsAwareTrait;
25
    use TranslatableTrait {
26
        __construct as protected initializeTranslationsCollection;
27
    }
28
29
    /** @var int */
30
    protected $id;
31
32
    /** @var string */
33
    protected $type;
34
35
    /** @var string */
36
    protected $code;
37
38
    /** @var string */
39
    protected $path;
40
41
    /** @var File */
42
    protected $file;
43
44
    /** @var string */
45
    protected $mimeType;
46
47
    /** @var string */
48
    protected $originalPath;
49
50
    public function __construct()
51
    {
52
        $this->initializeTranslationsCollection();
53
        $this->initializeSectionsCollection();
54
        $this->initializeProductsCollection();
55
    }
56
57
    public function getId(): ?int
58
    {
59
        return $this->id;
60
    }
61
62
    public function getType(): ?string
63
    {
64
        return $this->type;
65
    }
66
67
    public function setType(?string $type): void
68
    {
69
        $this->type = $type;
70
    }
71
72
    public function getCode(): ?string
73
    {
74
        return $this->code;
75
    }
76
77
    public function setCode(?string $code): void
78
    {
79
        $this->code = $code;
80
    }
81
82
    public function getPath(): ?string
83
    {
84
        return $this->path;
85
    }
86
87
    public function setPath(?string $path): void
88
    {
89
        $this->path = $path;
90
    }
91
92
    public function getFile(): ?File
93
    {
94
        return $this->file;
95
    }
96
97
    public function setFile(?File $file): void
98
    {
99
        $this->file = $file;
100
    }
101
102
    public function hasFile(): bool
103
    {
104
        return null !== $this->file;
105
    }
106
107
    public function getMimeType(): ?string
108
    {
109
        return $this->mimeType;
110
    }
111
112
    public function setMimeType(?string $mimeType): void
113
    {
114
        $this->mimeType = $mimeType;
115
    }
116
117
    public function getName(): ?string
118
    {
119
        return $this->getMediaTranslation()->getName();
120
    }
121
122
    public function setName(?string $name): void
123
    {
124
        $this->getMediaTranslation()->setName($name);
125
    }
126
127
    public function getDescription(): ?string
128
    {
129
        return $this->getMediaTranslation()->getDescription();
130
    }
131
132
    public function setDescription(?string $description): void
133
    {
134
        $this->getMediaTranslation()->setDescription($description);
135
    }
136
137
    public function getAlt(): ?string
138
    {
139
        return $this->getMediaTranslation()->getAlt();
140
    }
141
142
    public function setAlt(?string $alt): void
143
    {
144
        $this->getMediaTranslation()->setAlt($alt);
145
    }
146
147
    /**
148
     * @return MediaTranslationInterface|TranslationInterface
149
     */
150
    protected function getMediaTranslation(): TranslationInterface
151
    {
152
        return $this->getTranslation();
153
    }
154
155
    protected function createTranslation(): MediaTranslationInterface
156
    {
157
        return new MediaTranslation();
158
    }
159
}
160