Completed
Push — master ( 8d3dbf...7592af )
by Paweł
62:36
created

Image::setRenditions()   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
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Content Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\ContentBundle\Model;
16
17
use Doctrine\Common\Collections\ArrayCollection;
18
use SWP\Component\Common\Model\TimestampableTrait;
19
20
class Image implements ImageInterface
21
{
22
    use TimestampableTrait;
23
24
    /**
25
     * @var string
26
     */
27
    protected $id;
28
29
    /**
30
     * Uploaded file extension.
31
     *
32
     * @var string
33
     */
34
    protected $fileExtension;
35
36
    /**
37
     * @var string
38
     */
39
    protected $assetId;
40
41
    /**
42
     * @var ArticleMediaInterface
43
     */
44
    protected $media;
45
46
    /**
47
     * @var int
48
     */
49
    protected $width;
50
51
    /**
52
     * @var int
53
     */
54
    protected $height;
55
56
    /**
57
     * @var ArrayCollection
58
     */
59
    protected $renditions;
60
61
    /**
62
     * File constructor.
63
     */
64
    public function __construct()
65
    {
66
        $this->setCreatedAt(new \DateTime());
67
        $this->setRenditions(new ArrayCollection());
68
    }
69
70
    /**
71
     * @return ArticleMediaInterface
72
     */
73
    public function getMedia(): ArticleMediaInterface
74
    {
75
        return $this->media;
76
    }
77
78
    /**
79
     * @param ArticleMediaInterface $media
80
     */
81
    public function setMedia(ArticleMediaInterface $media)
82
    {
83
        $this->media = $media;
84
    }
85
86
    /**
87
     * @param string $id
88
     */
89
    public function setId($id)
90
    {
91
        $this->id = $id;
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97
    public function getId()
98
    {
99
        return $this->id;
100
    }
101
102
    /**
103
     * {@inheritdoc}
104
     */
105
    public function setFileExtension($extension)
106
    {
107
        $this->fileExtension = $extension;
108
    }
109
110
    /**
111
     * {@inheritdoc}
112
     */
113
    public function getFileExtension()
114
    {
115
        return $this->fileExtension;
116
    }
117
118
    /**
119
     * @return string
120
     */
121
    public function getAssetId(): string
122
    {
123
        return $this->assetId;
124
    }
125
126
    /**
127
     * {@inheritdoc}
128
     */
129
    public function setAssetId(string $assetId)
130
    {
131
        $this->assetId = $assetId;
132
    }
133
134
    /**
135
     * @return ArrayCollection
136
     */
137
    public function getRenditions()
138
    {
139
        return $this->renditions;
140
    }
141
142
    /**
143
     * @param ImageRendition $rendition
144
     */
145
    public function addRendition(ImageRendition $rendition)
146
    {
147
        $this->renditions->add($rendition);
148
    }
149
150
    /**
151
     * @param ArrayCollection $renditions
152
     */
153
    public function setRenditions($renditions)
154
    {
155
        $this->renditions = $renditions;
156
    }
157
158
    /**
159
     * {@inheritdoc}
160
     */
161
    public function getWidth()
162
    {
163
        return $this->width;
164
    }
165
166
    /**
167
     * Set the value of Width.
168
     *
169
     * @param int $width
170
     *
171
     * @return self
172
     */
173
    public function setWidth($width)
174
    {
175
        $this->width = $width;
176
177
        return $this;
178
    }
179
180
    /**
181
     * {@inheritdoc}
182
     */
183
    public function getHeight()
184
    {
185
        return $this->height;
186
    }
187
188
    /**
189
     * Set the value of Height.
190
     *
191
     * @param int $height
192
     *
193
     * @return self
194
     */
195
    public function setHeight($height)
196
    {
197
        $this->height = $height;
198
199
        return $this;
200
    }
201
}
202