Completed
Pull Request — master (#5)
by Bukashk0zzz
03:03 queued 26s
created

UserPictures::__load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 5
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
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
        $this->setPhotoName('photo.jpg')
96
            ->setCoverName('cover.jpg');
97
        $this->status = true;
98
    }
99
100
    /**
101
     * @inheritdoc
102
     */
103
    public function __isInitialized() {
104
        return $this->status;
105
    }
106
107
    /**
108
     * To string
109
     *
110
     * @return string
111
     */
112
    public function __toString()
113
    {
114
        $result = 'New Photo';
115
116
        return $result;
117
    }
118
119
    /**
120
     * Get photo name
121
     *
122
     * @return string Photo name
123
     */
124
    public function getPhotoName()
125
    {
126
        return $this->photoName;
127
    }
128
129
    /**
130
     * Set photo name
131
     *
132
     * @param string $photoName Photo name
133
     *
134
     * @return $this
135
     */
136
    public function setPhotoName($photoName)
137
    {
138
        $this->photoName = $photoName;
139
140
        return $this;
141
    }
142
143
    /**
144
     * Get photo file
145
     *
146
     * @return File Photo file
147
     */
148
    public function getPhotoFile()
149
    {
150
        return $this->photoFile;
151
    }
152
153
    /**
154
     * Set photo file
155
     *
156
     * @param File $photoFile Photo file
157
     *
158
     * @return $this
159
     */
160
    public function setPhotoFile(File $photoFile)
161
    {
162
        $this->photoFile = $photoFile;
163
164
        return $this;
165
    }
166
167
    /**
168
     * Get cover name
169
     *
170
     * @return string Cover name
171
     */
172
    public function getCoverName()
173
    {
174
        return $this->coverName;
175
    }
176
177
    /**
178
     * Set cover name
179
     *
180
     * @param string $coverName Cover name
181
     *
182
     * @return $this
183
     */
184
    public function setCoverName($coverName)
185
    {
186
        $this->coverName = $coverName;
187
188
        return $this;
189
    }
190
191
    /**
192
     * Get cover file
193
     *
194
     * @return File Cover file
195
     */
196
    public function getCoverFile()
197
    {
198
        return $this->coverFile;
199
    }
200
201
    /**
202
     * Set cover file
203
     *
204
     * @param File $coverFile Cover file
205
     *
206
     * @return $this
207
     */
208
    public function setCoverFile(File $coverFile)
209
    {
210
        $this->coverFile = $coverFile;
211
212
        return $this;
213
    }
214
215
    /**
216
     * Set userId
217
     *
218
     * @param integer $userId
219
     *
220
     * @return $this
221
     */
222
    public function setUserId($userId)
223
    {
224
        $this->userId = $userId;
225
226
        return $this;
227
    }
228
229
    /**
230
     * Get userId
231
     *
232
     * @return integer
233
     */
234
    public function getUserId()
235
    {
236
        return $this->userId;
237
    }
238
239
    /**
240
     * Set user
241
     *
242
     * @param UserA $user
243
     *
244
     * @return $this
245
     */
246
    public function setUser(UserA $user = null)
247
    {
248
        $this->user = $user;
249
250
        return $this;
251
    }
252
253
    /**
254
     * Get user
255
     *
256
     * @return UserA
257
     */
258
    public function getUser()
259
    {
260
        return $this->user;
261
    }
262
}
263