Completed
Pull Request — master (#15)
by Artem
01:18
created

UserPicture   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 181
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 13
c 4
b 1
f 0
lcom 0
cbo 0
dl 0
loc 181
rs 10
1
<?php
2
/*
3
 * This file is part of the FreshVichUploaderSerializationBundle
4
 *
5
 * (c) Artem Henvald <[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\Common\Persistence\Proxy;
14
use Doctrine\ORM\Mapping as ORM;
15
use Fresh\VichUploaderSerializationBundle\Annotation as Fresh;
16
use JMS\Serializer\Annotation as JMS;
17
use Symfony\Component\HttpFoundation\File\File;
18
use Vich\UploaderBundle\Mapping\Annotation as Vich;
19
20
/**
21
 * UserPictures Entity.
22
 *
23
 * @ORM\Table(name="userPictures")
24
 * @ORM\Entity()
25
 *
26
 * @JMS\ExclusionPolicy("all")
27
 *
28
 * @Vich\Uploadable
29
 *
30
 * @Fresh\VichSerializableClass
31
 */
32
class UserPicture implements Proxy
33
{
34
    /**
35
     * @var UserA
36
     *
37
     * @ORM\ManyToOne(targetEntity="Fresh\VichUploaderSerializationBundle\Tests\Fixtures\UserA", inversedBy="pictures")
38
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
39
     */
40
    private $user;
41
42
    /**
43
     * @var string
44
     *
45
     * @ORM\Column(type="string", length=255)
46
     *
47
     * @JMS\Expose
48
     * @JMS\SerializedName("photo")
49
     *
50
     * @Fresh\VichSerializableField("photoFile")
51
     */
52
    private $photoName;
53
54
    /**
55
     * @var File
56
     *
57
     * @JMS\Exclude
58
     *
59
     * @Vich\UploadableField(mapping="user_photo_mapping", fileNameProperty="photoName")
60
     */
61
    private $photoFile;
62
63
    /**
64
     * @var string
65
     *
66
     * @ORM\Column(type="string", length=255)
67
     *
68
     * @JMS\Expose
69
     * @JMS\SerializedName("cover")
70
     *
71
     * @Fresh\VichSerializableField("coverFile")
72
     */
73
    private $coverName;
74
75
    /**
76
     * @var File
77
     *
78
     * @JMS\Exclude
79
     *
80
     * @Vich\UploadableField(mapping="user_cover_mapping", fileNameProperty="coverName")
81
     */
82
    private $coverFile;
83
84
    /** @var bool */
85
    private $status = false;
86
87
    /**
88
     * @inheritdoc
89
     */
90
    public function __load()
91
    {
92
        $this->setPhotoName('photo.jpg')
93
             ->setCoverName('cover.jpg');
94
        $this->status = true;
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function __isInitialized()
101
    {
102
        return $this->status;
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    public function __toString()
109
    {
110
        return 'New User Picture';
111
    }
112
113
    /**
114
     * @param UserA $user
115
     *
116
     * @return $this
117
     */
118
    public function setUser(UserA $user = null)
119
    {
120
        $this->user = $user;
121
122
        return $this;
123
    }
124
125
    /**
126
     * @return UserA
127
     */
128
    public function getUser()
129
    {
130
        return $this->user;
131
    }
132
133
    /**
134
     * @return string
135
     */
136
    public function getPhotoName()
137
    {
138
        return $this->photoName;
139
    }
140
141
    /**
142
     * @param string $photoName
143
     *
144
     * @return $this
145
     */
146
    public function setPhotoName($photoName)
147
    {
148
        $this->photoName = $photoName;
149
150
        return $this;
151
    }
152
153
    /**
154
     * @return File
155
     */
156
    public function getPhotoFile()
157
    {
158
        return $this->photoFile;
159
    }
160
161
    /**
162
     * @param File $photoFile
163
     *
164
     * @return $this
165
     */
166
    public function setPhotoFile(File $photoFile)
167
    {
168
        $this->photoFile = $photoFile;
169
170
        return $this;
171
    }
172
173
    /**
174
     * @return string
175
     */
176
    public function getCoverName()
177
    {
178
        return $this->coverName;
179
    }
180
181
    /**
182
     * @param string $coverName
183
     *
184
     * @return $this
185
     */
186
    public function setCoverName($coverName)
187
    {
188
        $this->coverName = $coverName;
189
190
        return $this;
191
    }
192
193
    /**
194
     * @return File
195
     */
196
    public function getCoverFile()
197
    {
198
        return $this->coverFile;
199
    }
200
201
    /**
202
     * @param File $coverFile
203
     *
204
     * @return $this
205
     */
206
    public function setCoverFile(File $coverFile)
207
    {
208
        $this->coverFile = $coverFile;
209
210
        return $this;
211
    }
212
213
    /**
214
     * @param bool $status
215
     */
216
    public function setStatus($status)
217
    {
218
        $this->status = $status;
219
    }
220
}
221