Completed
Pull Request — develop (#251)
by
unknown
14:19 queued 06:05
created

Cv::setLanguageSkills()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 2
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Cv\Entity;
4
5
use Auth\Entity\InfoInterface;
6
use Auth\Entity\UserInterface;
7
use Core\Collection\IdentityWrapper;
8
use Core\Entity\AbstractIdentifiableEntity;
9
use Core\Entity\DraftableEntityInterface;
10
use Doctrine\Common\Collections\ArrayCollection;
11
use Doctrine\Common\Collections\Collection as CollectionInterface;
12
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
13
14
/**
15
 * Defines CV Model
16
 *
17
 * @ODM\Document(collection="cvs", repositoryClass="\Cv\Repository\Cv")
18
 * @ODM\Indexes({
19
 *     @ODM\Index(keys={
20
 *          "preferredJob.desiredJob"="text"
21
 *     },name="cvFulltext")
22
 * })
23
 */
24
class Cv extends AbstractIdentifiableEntity implements CvInterface, DraftableEntityInterface
25
{
26
    
27
    /**
28
     * Owner of the CV
29
     *
30
     * @var UserInterface
31
     * @ODM\ReferenceOne(targetDocument="\Auth\Entity\User", simple=true, cascade="persist")
32
     */
33
    protected $user;
34
    
35
    /**
36
     * personal informations, contains firstname, lastname, email,
37
     * phone etc.
38
     *
39
     * @ODM\EmbedOne(targetDocument="Contact")
40
     */
41
    protected $contact;
42
    
43
    /**
44
     * Education History
45
     *
46
     * @var ArrayCollection
47
     * @ODM\EmbedMany(targetDocument="\Cv\Entity\Education")
48
     */
49
    protected $educations;
50
    
51
    /**
52
     * Employment History
53
     *
54
     * @var ArrayCollection
55
     * @ODM\EmbedMany(targetDocument="\Cv\Entity\Employment")
56
     */
57
    protected $employments;
58
    
59
    /**
60
     * Skills
61
     *
62
     * @var ArrayCollection
63
     * @ODM\EmbedMany(targetDocument="\Cv\Entity\Skill")
64
     */
65
    protected $skills;
66
67
    /**
68
    * Skills
69
    *
70
    * @var ArrayCollection
71
    * @ODM\EmbedMany(targetDocument="\Cv\Entity\Language")
72
    */
73
    protected $languageSkills;
74
75
    /**
76
     * @var array
77
     * @ODM\Collection
78
     */
79
    protected $nativeLanguages=[];
80
81
82
    /**
83
     * Preferred Job. Where do the user want to work? What kind of work he wants do do
84
     *
85
     * @ODM\EmbedOne(targetDocument="\Cv\Entity\PreferredJob")
86
     */
87
    protected $preferredJob;
88
89
    /**
90
     * Flag indicating draft state of this cv.
91
     *
92
     * @var bool
93
     * @ODM\Boolean
94
     */
95
    protected $isDraft = false;
96
    
97
    /**
98
     * Status
99
     *
100
     * @var Status
101
     * @ODM\EmbedOne(targetDocument="Status")
102
     * @ODM\Index
103
     */
104
    protected $status;
105
    
106
    /**
107
     * Multiple attachments
108
     *
109
     * @ODM\ReferenceMany(targetDocument="Attachment", simple="true", cascade={"persist", "remove"})
110
     */
111
    protected $attachments;
112
113
    public function __construct()
114
    {
115
        $this->status = new Status();
116
    }
117
    
118
    /**
119
     * @return UserInterface
120
     */
121
    public function getUser()
122
    {
123
        return $this->user;
124
    }
125
126
    /**
127
     * @param UserInterface $user
128
     * @return $this
129
     */
130
    public function setUser(UserInterface $user)
131
    {
132
        $this->user = $user;
133
        return $this;
134
    }
135
    
136
    /**
137
     * @return Contact
138
     */
139
    public function getContact()
140
    {
141
        return $this->contact;
142
    }
143
    
144
    /**
145
     * @return Cv
146
     */
147
    public function setContact(InfoInterface $contact)
148
    {
149
        if (!$contact instanceof Contact) {
150
            $contact = new Contact($contact);
151
        }
152
        $this->contact = $contact;
153
        return $this;
154
    }
155
    
156
    /**
157
     * @return ArrayCollection
158
     */
159
    public function getEducations()
160
    {
161
        if (!$this->educations) {
162
            $this->setEducations(new ArrayCollection());
163
        }
164
        return $this->educations;
165
    }
166
    
167
    /**
168
     * @return ArrayCollection
0 ignored issues
show
Documentation introduced by
Should the return type not be IdentityWrapper?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
169
     */
170
    public function getEducationsIndexedById()
171
    {
172
        return new IdentityWrapper($this->getEducations());
173
    }
174
175
    /**
176
     * @param CollectionInterface $educations
177
     * @return $this
178
     */
179
    public function setEducations(CollectionInterface $educations)
180
    {
181
        $this->educations = $educations;
0 ignored issues
show
Documentation Bug introduced by
$educations is of type object<Doctrine\Common\Collections\Collection>, but the property $educations was declared to be of type object<Doctrine\Common\C...ctions\ArrayCollection>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
182
        return $this;
183
    }
184
185
    /**
186
     * @return ArrayCollection
187
     */
188
    public function getEmployments()
189
    {
190
        if (!$this->employments) {
191
            $this->setEmployments(new ArrayCollection());
192
        }
193
        return $this->employments;
194
    }
195
    
196
    /**
197
     * @return ArrayCollection
0 ignored issues
show
Documentation introduced by
Should the return type not be IdentityWrapper?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
198
     */
199
    public function getEmploymentsIndexedById()
200
    {
201
        return new IdentityWrapper($this->getEmployments());
202
    }
203
204
    /**
205
     * @param CollectionInterface $employments
206
     * @return $this
207
     */
208
    public function setEmployments(CollectionInterface $employments)
209
    {
210
        $this->employments = $employments;
0 ignored issues
show
Documentation Bug introduced by
$employments is of type object<Doctrine\Common\Collections\Collection>, but the property $employments was declared to be of type object<Doctrine\Common\C...ctions\ArrayCollection>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
211
        return $this;
212
    }
213
    
214
    /**
215
     * @return ArrayCollection
216
     */
217
    public function getSkills()
218
    {
219
        if (!$this->skills) {
220
            $this->setSkills(new ArrayCollection());
221
        }
222
        return $this->skills;
223
    }
224
    
225
    /**
226
     * @return ArrayCollection
0 ignored issues
show
Documentation introduced by
Should the return type not be IdentityWrapper?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
227
     */
228
    public function getSkillsIndexedById()
229
    {
230
        return new IdentityWrapper($this->getSkills());
231
    }
232
233
    /**
234
     * @param CollectionInterface $skills
235
     * @return $this
236
     */
237
    public function setSkills(CollectionInterface $skills)
238
    {
239
        $this->skills = $skills;
0 ignored issues
show
Documentation Bug introduced by
$skills is of type object<Doctrine\Common\Collections\Collection>, but the property $skills was declared to be of type object<Doctrine\Common\C...ctions\ArrayCollection>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
240
        return $this;
241
    }
242
243
    /**
244
     * @param bool $isDraft
245
     * @return $this
246
     */
247
    public function setIsDraft($isDraft)
248
    {
249
        $this->isDraft=$isDraft;
250
        return $this;
251
    }
252
253
    /**
254
     * @return boolean
255
     */
256
    public function isDraft()
257
    {
258
        return $this->isDraft;
259
    }
260
261
    /**
262
     * @return \Cv\Entity\PreferredJobInterface
263
     */
264
    public function getPreferredJob()
265
    {
266
        if (null == $this->preferredJob) {
267
            $this->preferredJob = new PreferredJob();
268
        }
269
        return $this->preferredJob;
270
    }
271
272
    /**
273
     * @param \Cv\Entity\PreferredJobInterface $preferredJob
274
     * @return $this
275
     */
276
    public function setPreferredJob(PreferredJobInterface $preferredJob)
277
    {
278
        $this->preferredJob = $preferredJob;
279
        return $this;
280
    }
281
282
    /**
283
     * @return ArrayCollection
284
     */
285
    public function getLanguageSkills()
286
    {
287
        if (!$this->languageSkills) {
288
            $this->setLanguageSkills(new ArrayCollection());
289
        }
290
        return $this->languageSkills;
291
    }
292
293
    /**
294
     * @param CollectionInterface $languageSkills
295
     * @return $this
296
     */
297
    public function setLanguageSkills(CollectionInterface $languageSkills)
298
    {
299
        $this->languageSkills = $languageSkills;
0 ignored issues
show
Documentation Bug introduced by
$languageSkills is of type object<Doctrine\Common\Collections\Collection>, but the property $languageSkills was declared to be of type object<Doctrine\Common\C...ctions\ArrayCollection>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
300
        return $this;
301
    }
302
303
    /**
304
     * @return ArrayCollection
0 ignored issues
show
Documentation introduced by
Should the return type not be IdentityWrapper?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
305
     */
306
    public function getLanguageSkillsIndexedById()
307
    {
308
        return new IdentityWrapper($this->getLanguageSkills());
309
    }
310
311
    /**
312
     * Sets the mothers tongue of the candidate
313
     *
314
     * @param array
315
     * @return $this
316
     */
317
    public function setNativeLanguages($nativeLanguages)
318
    {
319
        $this->nativeLanguages=$nativeLanguages;
320
        return $this;
321
    }
322
323
    /**
324
     * Gets the mothers tongue of the candidate
325
     *
326
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be array?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
327
     */
328
    public function getNativeLanguages()
329
    {
330
        return $this->nativeLanguages;
331
    }
332
    
333
    /**
334
     * @return Status
335
     */
336
    public function getStatus()
337
    {
338
        if (!isset($this->status)) {
339
            $this->status = new Status();
340
        }
341
    
342
        return $this->status;
343
    }
344
    
345
    /**
346
     * @param Status|string $status
347
     */
348
    public function setStatus($status)
349
    {
350
        if (!$status instanceof Status) {
351
            $status = new Status($status);
352
        }
353
    
354
        $this->status = $status;
355
    }
356
357
    /**
358
     * @param CollectionInterface $attachments
359
     * @return Cv
360
     */
361
    public function setAttachments(CollectionInterface $attachments)
362
    {
363
        $this->attachments = $attachments;
364
        return $this;
365
    }
366
367
    /**
368
     * @return CollectionInterface
369
     */
370
    public function getAttachments()
371
    {
372
        if (!$this->attachments) {
373
            $this->setAttachments(new ArrayCollection());
374
        }
375
        return $this->attachments;
376
    }
377
}
378