Completed
Push — develop ( 728aa6...c30dd4 )
by
unknown
17:43 queued 10:24
created

Cv   C

Complexity

Total Complexity 36

Size/Duplication

Total Lines 357
Duplicated Lines 0 %

Coupling/Cohesion

Components 8
Dependencies 6

Importance

Changes 11
Bugs 0 Features 1
Metric Value
wmc 36
c 11
b 0
f 1
lcom 8
cbo 6
dl 0
loc 357
rs 6.7692

27 Methods

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