Completed
Push — develop ( c635bd...85470e )
by
unknown
17:23 queued 09:19
created

Cv::getEmploymentsIndexedById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
    public function __construct()
107
    {
108
        $this->status = new Status();
109
    }
110
    
111
    /**
112
     * @return UserInterface
113
     */
114
    public function getUser()
115
    {
116
        return $this->user;
117
    }
118
119
    /**
120
     * @param UserInterface $user
121
     * @return $this
122
     */
123
    public function setUser(UserInterface $user)
124
    {
125
        $this->user = $user;
126
        return $this;
127
    }
128
    
129
    /**
130
     * @return Contact
131
     */
132
    public function getContact()
133
    {
134
        return $this->contact;
135
    }
136
    
137
    /**
138
     * @return Cv
139
     */
140
    public function setContact(InfoInterface $contact)
141
    {
142
        if (!$contact instanceof Contact) {
143
            $contact = new Contact($contact);
144
        }
145
        $this->contact = $contact;
146
        return $this;
147
    }
148
    
149
    /**
150
     * @return ArrayCollection
151
     */
152
    public function getEducations()
153
    {
154
        if (!$this->educations) {
155
            $this->setEducations(new ArrayCollection());
156
        }
157
        return $this->educations;
158
    }
159
    
160
    /**
161
     * @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...
162
     */
163
    public function getEducationsIndexedById()
164
    {
165
        return new IdentityWrapper($this->getEducations());
166
    }
167
168
    /**
169
     * @param CollectionInterface $educations
170
     * @return $this
171
     */
172
    public function setEducations(CollectionInterface $educations)
173
    {
174
        $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...
175
        return $this;
176
    }
177
178
    /**
179
     * @return ArrayCollection
180
     */
181
    public function getEmployments()
182
    {
183
        if (!$this->employments) {
184
            $this->setEmployments(new ArrayCollection());
185
        }
186
        return $this->employments;
187
    }
188
    
189
    /**
190
     * @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...
191
     */
192
    public function getEmploymentsIndexedById()
193
    {
194
        return new IdentityWrapper($this->getEmployments());
195
    }
196
197
    /**
198
     * @param CollectionInterface $employments
199
     * @return $this
200
     */
201
    public function setEmployments(CollectionInterface $employments)
202
    {
203
        $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...
204
        return $this;
205
    }
206
    
207
    /**
208
     * @return ArrayCollection
209
     */
210
    public function getSkills()
211
    {
212
        if (!$this->skills) {
213
            $this->setSkills(new ArrayCollection());
214
        }
215
        return $this->skills;
216
    }
217
    
218
    /**
219
     * @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...
220
     */
221
    public function getSkillsIndexedById()
222
    {
223
        return new IdentityWrapper($this->getSkills());
224
    }
225
226
    /**
227
     * @param CollectionInterface $skills
228
     * @return $this
229
     */
230
    public function setSkills(CollectionInterface $skills)
231
    {
232
        $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...
233
        return $this;
234
    }
235
236
    /**
237
     * @param bool $isDraft
238
     * @return $this
239
     */
240
    public function setIsDraft($isDraft)
241
    {
242
        $this->isDraft=$isDraft;
243
        return $this;
244
    }
245
246
    /**
247
     * @return boolean
248
     */
249
    public function isDraft()
250
    {
251
        return $this->isDraft;
252
    }
253
254
    /**
255
     * @return \Cv\Entity\PreferredJobInterface
256
     */
257
    public function getPreferredJob()
258
    {
259
        if (null == $this->preferredJob) {
260
            $this->preferredJob = new PreferredJob();
261
        }
262
        return $this->preferredJob;
263
    }
264
265
    /**
266
     * @param \Cv\Entity\PreferredJobInterface $preferredJob
267
     * @return $this
268
     */
269
    public function setPreferredJob(PreferredJobInterface $preferredJob)
270
    {
271
        $this->preferredJob = $preferredJob;
272
        return $this;
273
    }
274
275
    /**
276
     * @return ArrayCollection
277
     */
278
    public function getLanguageSkills()
279
    {
280
        if (!$this->languageSkills) {
281
            $this->setLanguageSkills(new ArrayCollection());
282
        }
283
        return $this->languageSkills;
284
    }
285
286
    /**
287
     * @param CollectionInterface $languageSkills
288
     * @return $this
289
     */
290
    public function setLanguageSkills(CollectionInterface $languageSkills)
291
    {
292
        $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...
293
        return $this;
294
    }
295
296
    /**
297
     * @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...
298
     */
299
    public function getLanguageSkillsIndexedById()
300
    {
301
        return new IdentityWrapper($this->getLanguageSkills());
302
    }
303
304
    /**
305
     * Sets the mothers tongue of the candidate
306
     *
307
     * @param array
308
     * @return $this
309
     */
310
    public function setNativeLanguages($nativeLanguages)
311
    {
312
        $this->nativeLanguages=$nativeLanguages;
313
        return $this;
314
    }
315
316
    /**
317
     * Gets the mothers tongue of the candidate
318
     *
319
     * @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...
320
     */
321
    public function getNativeLanguages()
322
    {
323
        return $this->nativeLanguages;
324
    }
325
    
326
    /**
327
     * @return Status
328
     */
329
    public function getStatus()
330
    {
331
        if (!isset($this->status)) {
332
            $this->status = new Status();
333
        }
334
    
335
        return $this->status;
336
    }
337
    
338
    /**
339
     * @param Status|string $status
340
     */
341
    public function setStatus($status)
342
    {
343
        if (!$status instanceof Status) {
344
            $status = new Status($status);
345
        }
346
    
347
        $this->status = $status;
348
    }
349
}
350