Completed
Push — develop ( c61561...247dd8 )
by
unknown
09:15
created

Cv::getLanguageSkills()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Cv\Entity;
4
5
use Core\Entity\AbstractIdentifiableEntity;
6
use Doctrine\Common\Collections\Collection as CollectionInterface;
7
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
8
use Auth\Entity\UserInterface;
9
use Doctrine\Common\Collections\ArrayCollection;
10
use Core\Entity\DraftableEntityInterface;
11
use Auth\Entity\InfoInterface;
12
use Core\Collection\IdentityWrapper;
13
14
/**
15
 *
16
 * @ODM\Document(collection="cvs", repositoryClass="\Cv\Repository\Cv")
17
 */
18
class Cv extends AbstractIdentifiableEntity implements CvInterface, DraftableEntityInterface
19
{
20
    
21
    /**
22
     * Owner of the CV
23
     *
24
     * @var UserInterface
25
     * @ODM\ReferenceOne(targetDocument="\Auth\Entity\User", simple=true)
26
     * @ODM\Index
27
     */
28
    protected $user;
29
    
30
    /**
31
     * personal informations, contains firstname, lastname, email,
32
     * phone etc.
33
     *
34
     * @ODM\EmbedOne(targetDocument="Contact")
35
     */
36
    protected $contact;
37
    
38
    /**
39
     * Education History
40
     *
41
     * @var ArrayCollection
42
     * @ODM\EmbedMany(targetDocument="\Cv\Entity\Education")
43
     */
44
    protected $educations;
45
    
46
    /**
47
     * Employment History
48
     *
49
     * @var ArrayCollection
50
     * @ODM\EmbedMany(targetDocument="\Cv\Entity\Employment")
51
     */
52
    protected $employments;
53
    
54
    /**
55
     * Skills
56
     *
57
     * @var ArrayCollection
58
     * @ODM\EmbedMany(targetDocument="\Cv\Entity\Skill")
59
     */
60
    protected $skills;
61
62
    /**
63
    * Skills
64
    *
65
    * @var ArrayCollection
66
    * @ODM\EmbedMany(targetDocument="\Cv\Entity\Language")
67
    */
68
    protected $languageSkills;
69
70
    /**
71
     * @var array
72
     * @ODM\Collection
73
     */
74
    protected $nativeLanguages=[];
75
76
77
    /**
78
     * Preferred Job. Where do the user want to work? What kind of work he wants do do
79
     *
80
     * @ODM\EmbedOne(targetDocument="\Cv\Entity\PreferredJob")
81
     */
82
    protected $preferredJob;
83
84
    /**
85
     * Flag indicating draft state of this cv.
86
     *
87
     * @var bool
88
     * @ODM\Boolean
89
     */
90
    protected $isDraft = false;
91
92
    /**
93
     * @return UserInterface
94
     */
95
    public function getUser()
96
    {
97
        return $this->user;
98
    }
99
100
    /**
101
     * @param UserInterface $user
102
     * @return $this
103
     */
104
    public function setUser(UserInterface $user)
105
    {
106
        $this->user = $user;
107
        return $this;
108
    }
109
    
110
    /**
111
     * @return Contact
112
     */
113
    public function getContact()
114
    {
115
        return $this->contact;
116
    }
117
    
118
    /**
119
     * @return Cv
120
     */
121
    public function setContact(InfoInterface $contact)
122
    {
123
        if (!$contact instanceof Contact) {
124
            $contact = new Contact($contact);
125
        }
126
        $this->contact = $contact;
127
        return $this;
128
    }
129
    
130
    /**
131
     * @return ArrayCollection
132
     */
133
    public function getEducations()
134
    {
135
        if (!$this->educations) {
136
            $this->setEducations(new ArrayCollection());
137
        }
138
        return $this->educations;
139
    }
140
    
141
    /**
142
     * @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...
143
     */
144
    public function getEducationsIndexedById()
145
    {
146
        return new IdentityWrapper($this->getEducations());
147
    }
148
149
    /**
150
     * @param CollectionInterface $educations
151
     * @return $this
152
     */
153
    public function setEducations(CollectionInterface $educations)
154
    {
155
        $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...
156
        return $this;
157
    }
158
159
    /**
160
     * @return ArrayCollection
161
     */
162
    public function getEmployments()
163
    {
164
        if (!$this->employments) {
165
            $this->setEmployments(new ArrayCollection());
166
        }
167
        return $this->employments;
168
    }
169
    
170
    /**
171
     * @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...
172
     */
173
    public function getEmploymentsIndexedById()
174
    {
175
        return new IdentityWrapper($this->getEmployments());
176
    }
177
178
    /**
179
     * @param CollectionInterface $employments
180
     * @return $this
181
     */
182
    public function setEmployments(CollectionInterface $employments)
183
    {
184
        $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...
185
        return $this;
186
    }
187
    
188
    /**
189
     * @return ArrayCollection
190
     */
191
    public function getSkills()
192
    {
193
        if (!$this->skills) {
194
            $this->setSkills(new ArrayCollection());
195
        }
196
        return $this->skills;
197
    }
198
    
199
    /**
200
     * @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...
201
     */
202
    public function getSkillsIndexedById()
203
    {
204
        return new IdentityWrapper($this->getSkills());
205
    }
206
207
    /**
208
     * @param CollectionInterface $skills
209
     * @return $this
210
     */
211
    public function setSkills(CollectionInterface $skills)
212
    {
213
        $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...
214
        return $this;
215
    }
216
217
    public function setIsDraft($isDraft)
218
    {
219
        $this->isDraft=$isDraft;
220
        return $this;
221
    }
222
223
    /**
224
     * @return boolean
225
     */
226
    public function isDraft()
227
    {
228
        return $this->isDraft;
229
    }
230
231
    /**
232
     * @return \PreferredJobInterface
233
     */
234
    public function getPreferredJob()
235
    {
236
        if (null == $this->preferredJob) {
237
            $this->preferredJob = new PreferredJob();
238
        }
239
        return $this->preferredJob;
240
    }
241
242
    /**
243
     * @param \PreferredJobInterface $preferredJob
244
     * @return $this
245
     */
246
    public function setPreferredJob(\PreferredJobInterface $preferredJob)
247
    {
248
        $this->preferredJob = $preferredJob;
249
        return $this;
250
    }
251
252
    /**
253
     * @return ArrayCollection
254
     */
255
    public function getLanguageSkills()
256
    {
257
        if (!$this->languageSkills) {
258
            $this->setLanguageSkills(new ArrayCollection());
259
        }
260
        return $this->languageSkills;
261
    }
262
263
    /**
264
     * @param CollectionInterface $skills
0 ignored issues
show
Documentation introduced by
There is no parameter named $skills. Did you maybe mean $languageSkills?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
265
     * @return $this
266
     */
267
    public function setLanguageSkills(CollectionInterface $languageSkills)
268
    {
269
        $this->getLanguageSkills = $languageSkills;
0 ignored issues
show
Bug introduced by
The property getLanguageSkills does not seem to exist. Did you mean skills?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
270
        return $this;
271
    }
272
    /**
273
     * @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...
274
     */
275
    public function getLanguageSkillsIndexedById()
276
    {
277
        return new IdentityWrapper($this->getLanguageSkills());
278
    }
279
    /**
280
     * Sets the mothers tongue of the candidate
281
     *
282
     * @param array
283
     * @return $this
284
     */
285
    public function setNativeLanguages($nativeLanguages)
286
    {
287
        $this->nativeLanguages=$nativeLanguages;
288
        return $this;
289
    }
290
291
    /**
292
     * Gets the mothers tongue of the candidate
293
     *
294
     * @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...
295
     */
296
    public function getNativeLanguages()
297
    {
298
        return $this->nativeLanguages;
299
    }
300
}
301