Completed
Push — master ( 992272...53e0af )
by Artem
07:29
created

UserPictures::setCoverFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of the FreshVichUploaderSerializationBundle
4
 *
5
 * (c) Artem Genvald <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Fresh\VichUploaderSerializationBundle\Tests\Fixtures;
12
13
use Doctrine\ORM\Mapping as ORM;
14
use Fresh\VichUploaderSerializationBundle\Annotation as Fresh;
15
use JMS\Serializer\Annotation as JMS;
16
use Symfony\Component\HttpFoundation\File\File;
17
use Vich\UploaderBundle\Mapping\Annotation as Vich;
18
use Doctrine\Common\Persistence\Proxy;
19
20
/**
21
 * UserPictures Entity
22
 *
23
 * @ORM\Table(name="userPictures")
24
 * @ORM\Entity()
25
 *
26
 * @JMS\ExclusionPolicy("all")
27
 *
28
 * @Vich\Uploadable
29
 * @Fresh\VichSerializableClass
30
 */
31
class UserPictures implements Proxy
32
{
33
    /**
34
     * @ORM\ManyToOne(targetEntity="Fresh\VichUploaderSerializationBundle\Tests\Fixtures\UserA", inversedBy="pictures")
35
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
36
     */
37
    protected $user;
38
39
    /**
40
     * @ORM\Column(type="integer")
41
     */
42
    protected $userId;
43
44
    /**
45
     * @var string $photoName Photo name
46
     *
47
     * @ORM\Column(type="string", length=255)
48
     *
49
     * @JMS\Expose
50
     * @JMS\SerializedName("photo")
51
     *
52
     * @Fresh\VichSerializableField("photoFile")
53
     */
54
    private $photoName;
55
56
    /**
57
     * @var File $photoFile Photo file
58
     *
59
     * @JMS\Exclude
60
     *
61
     * @Vich\UploadableField(mapping="user_photo_mapping", fileNameProperty="photoName")
62
     */
63
    private $photoFile;
64
65
    /**
66
     * @var string $coverName Cover name
67
     *
68
     * @ORM\Column(type="string", length=255)
69
     *
70
     * @JMS\Expose
71
     * @JMS\SerializedName("cover")
72
     *
73
     * @Fresh\VichSerializableField("coverFile")
74
     */
75
    private $coverName;
76
77
    /**
78
     * @var File $coverFile Cover file
79
     *
80
     * @JMS\Exclude
81
     *
82
     * @Vich\UploadableField(mapping="user_cover_mapping", fileNameProperty="coverName")
83
     */
84
    private $coverFile;
85
86
    /**
87
     * @var bool
88
     */
89
    private $status = false;
90
91
    /**
92
     * @inheritdoc
93
     */
94
    public function __load()
95
    {
96
        $this->setPhotoName('photo.jpg')
97
            ->setCoverName('cover.jpg');
98
        $this->status = true;
99
    }
100
101
    /**
102
     * @inheritdoc
103
     * @return bool
104
     */
105
    public function __isInitialized()
106
    {
107
        return $this->status;
108
    }
109
110
    /**
111
     * To string
112
     *
113
     * @return string
114
     */
115
    public function __toString()
116
    {
117
        $result = 'New Photo';
118
119
        return $result;
120
    }
121
122
    /**
123
     * Get photo name
124
     *
125
     * @return string Photo name
126
     */
127
    public function getPhotoName()
128
    {
129
        return $this->photoName;
130
    }
131
132
    /**
133
     * Set photo name
134
     *
135
     * @param string $photoName Photo name
136
     *
137
     * @return $this
138
     */
139
    public function setPhotoName($photoName)
140
    {
141
        $this->photoName = $photoName;
142
143
        return $this;
144
    }
145
146
    /**
147
     * Get photo file
148
     *
149
     * @return File Photo file
150
     */
151
    public function getPhotoFile()
152
    {
153
        return $this->photoFile;
154
    }
155
156
    /**
157
     * Set photo file
158
     *
159
     * @param File $photoFile Photo file
160
     *
161
     * @return $this
162
     */
163
    public function setPhotoFile(File $photoFile)
164
    {
165
        $this->photoFile = $photoFile;
166
167
        return $this;
168
    }
169
170
    /**
171
     * Get cover name
172
     *
173
     * @return string Cover name
174
     */
175
    public function getCoverName()
176
    {
177
        return $this->coverName;
178
    }
179
180
    /**
181
     * Set cover name
182
     *
183
     * @param string $coverName Cover name
184
     *
185
     * @return $this
186
     */
187
    public function setCoverName($coverName)
188
    {
189
        $this->coverName = $coverName;
190
191
        return $this;
192
    }
193
194
    /**
195
     * Get cover file
196
     *
197
     * @return File Cover file
198
     */
199
    public function getCoverFile()
200
    {
201
        return $this->coverFile;
202
    }
203
204
    /**
205
     * Set cover file
206
     *
207
     * @param File $coverFile Cover file
208
     *
209
     * @return $this
210
     */
211
    public function setCoverFile(File $coverFile)
212
    {
213
        $this->coverFile = $coverFile;
214
215
        return $this;
216
    }
217
218
    /**
219
     * Set userId
220
     *
221
     * @param integer $userId
222
     *
223
     * @return $this
224
     */
225
    public function setUserId($userId)
226
    {
227
        $this->userId = $userId;
228
229
        return $this;
230
    }
231
232
    /**
233
     * Get userId
234
     *
235
     * @return integer
236
     */
237
    public function getUserId()
238
    {
239
        return $this->userId;
240
    }
241
242
    /**
243
     * Set user
244
     *
245
     * @param UserA $user
246
     *
247
     * @return $this
248
     */
249
    public function setUser(UserA $user = null)
250
    {
251
        $this->user = $user;
252
253
        return $this;
254
    }
255
256
    /**
257
     * Get user
258
     *
259
     * @return UserA
260
     */
261
    public function getUser()
262
    {
263
        return $this->user;
264
    }
265
}
266