Passed
Push — develop ( 1cdaea...12a68b )
by Mathias
12:21 queued 04:15
created

TemplateValues   A

Complexity

Total Complexity 33

Size/Duplication

Total Lines 350
Duplicated Lines 0 %

Test Coverage

Coverage 38.46%

Importance

Changes 0
Metric Value
wmc 33
eloc 65
dl 0
loc 350
ccs 30
cts 78
cp 0.3846
rs 9.76
c 0
b 0
f 0

23 Methods

Rating   Name   Duplication   Size   Complexity  
A setRequirements() 0 4 1
A setDescription() 0 4 1
A getQualifications() 0 3 1
A setLanguage() 0 4 1
A setBenefits() 0 4 1
A setHtml() 0 5 1
A setIntroduction() 0 5 1
A setTitle() 0 4 1
A set() 0 5 1
A get() 0 9 3
A getBenefits() 0 3 1
A setQualifications() 0 4 1
A getHtml() 0 3 1
A getDescription() 0 3 1
A getLanguage() 0 3 1
A setBoilerplate() 0 5 1
A __set() 0 15 3
A __isset() 0 11 5
A __get() 0 12 3
A getBoilerplate() 0 3 1
A getIntroduction() 0 3 1
A getRequirements() 0 3 1
A getTitle() 0 3 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 * @author    [email protected]
9
 */
10
11
namespace Jobs\Entity;
12
13
use Core\Entity\AbstractEntity;
14
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
15
16
/**
17
 * Holds various fields a o job opening template
18
 *
19
 * @ODM\EmbeddedDocument
20
 * @ODM\Indexes({
21
 *   @ODM\Index(keys={"requirements"="text",
22
 *                    "description"="text",
23
 *                    "qualifications"="text",
24
 *                    "benefits"="text",
25
 *                    "title"="text"},
26
 *              name="fulltext",
27
 *              options={"language_override":"lang_index"})
28
 * })
29
 * @since 0.29 Adds html field.
30
 * @since 0.33 Add option 'language_override' to index definition.
31
 */
32
class TemplateValues extends AbstractEntity implements TemplateValuesInterface
33
{
34
35
    /**
36
     * Qualification field of the job template
37
     *
38
     * @var String
39
     * @ODM\Field(type="string")
40
     */
41
    protected $qualifications='';
42
43
    /**
44
     * Requirements field of the job template
45
     *
46
     * @var String
47
     * @ODM\Field(type="string")
48
     */
49
    protected $requirements='';
50
51
    /**
52
     * Benefits field of the job template
53
     *
54
     * @var String
55
     * @ODM\Field(type="string")
56
     */
57
    protected $benefits='';
58
59
    /**
60
     * Job title field of the job template
61
     *
62
     * @var String
63
     * @ODM\Field(type="string")
64
     */
65
    protected $title='';
66
67
    /**
68
     * Company description field of the job template
69
     *
70
     * @var String
71
     * @ODM\Field(type="string")
72
     */
73
    protected $description='';
74
75
    /**
76
     * language of the job template values. Must be a valid ISO 639-1 code
77
     *
78
     * @var String
79
     * @ODM\Field(type="string")
80
     */
81
    protected $language='en';
82
83
    /**
84
     * Pure HTML
85
     *
86
     * @ODM\Field(type="string")
87
     * @var string
88
     * @since 0.29
89
     */
90
    protected $html='';
91
92
    /**
93
     * Introduction text for the job template
94
     *
95
     * @ODM\Field(type="string")
96
     * @var string
97
     */
98
    protected $introduction = '';
99
100
    /**
101
     * Boilerplate (outro) text for the job template
102
     *
103
     * @ODM\Field(type="string")
104
     * @var string
105
     */
106
    protected $boilerplate = '';
107
108
    /**
109
     * free values (currently not in use)
110
     *
111
     * @ODM\Field(type="hash")
112
     */
113
    protected $_freeValues;
114
115
    /**
116
     * Sets the Qualification field of the job template
117
     *
118
     * @param $qualifications
119
     * @return $this
120
     */
121 1
    public function setQualifications($qualifications)
122
    {
123 1
        $this->qualifications= (string) $qualifications;
124 1
        return $this;
125
    }
126
127
    /**
128
     * Gets the qualification of a job template
129
     *
130
     * @return String
131
     */
132 2
    public function getQualifications()
133
    {
134 2
        return $this->qualifications;
135
    }
136
137
    /**
138
     * Sets the requirements of a job template
139
     *
140
     * @param String $requirements
141
     * @return $this
142
     */
143 1
    public function setRequirements($requirements)
144
    {
145 1
        $this->requirements=(string) $requirements;
146 1
        return $this;
147
    }
148
149
    /**
150
     * Gets the requirements of a job template
151
     *
152
     * @return String
153
     */
154 2
    public function getRequirements()
155
    {
156 2
        return $this->requirements;
157
    }
158
159
    /**
160
     * Sets the benefits of a job template
161
     *
162
     * @param String $benefits
163
     * @return $this
164
     */
165 1
    public function setBenefits($benefits)
166
    {
167 1
        $this->benefits=(string) $benefits;
168 1
        return $this;
169
    }
170
171
    /**
172
     * Gets the Benefits of a job template
173
     *
174
     * @return String
175
     */
176 2
    public function getBenefits()
177
    {
178 2
        return $this->benefits;
179
    }
180
181
    /**
182
     * Sets the job title of the job template
183
     *
184
     * @param $title
185
     * @return $this
186
     */
187 1
    public function setTitle($title)
188
    {
189 1
        $this->title=(string) $title;
190 1
        return $this;
191
    }
192
193
    /**
194
     * Gets the job title of the job template
195
     *
196
     * @return String
197
     */
198 2
    public function getTitle()
199
    {
200 2
        return $this->title;
201
    }
202
203
    /**
204
     * Sets the company description of the job template
205
     *
206
     * @param $description
207
     * @return $this
208
     */
209 1
    public function setDescription($description)
210
    {
211 1
        $this->description=(string) $description;
212 1
        return $this;
213
    }
214
215
    /**
216
     * Gets the company description of the job template
217
     *
218
     * @return String
219
     */
220 1
    public function getDescription()
221
    {
222 1
        return $this->description;
223
    }
224
225
    /**
226
     * Sets the language of the job template values
227
     *
228
     * @param $language
229
     * @return $this
230
     */
231 1
    public function setLanguage($language)
232
    {
233 1
        $this->language=(string) $language;
234 1
        return $this;
235
    }
236
237
    /**
238
     * Gets the language of the job template values
239
     *
240
     * @return String
241
     */
242 2
    public function getLanguage()
243
    {
244 2
        return $this->language;
245
    }
246
247
    /**
248
     * @param string $html
249
     *
250
     * @return self
251
     * @since 0.29
252
     */
253
    public function setHtml($html)
254
    {
255
        $this->html = $html;
256
257
        return $this;
258
    }
259
260
    /**
261
     * @return string
262
     * @since 0.29
263
     */
264
    public function getHtml()
265
    {
266
        return $this->html;
267
    }
268
269
    /**
270
     * @return string
271
     */
272
    public function getIntroduction(): string
273
    {
274
        return $this->introduction;
275
    }
276
277
    /**
278
     * @param string $introduction
279
     *
280
     * @return self
281
     */
282
    public function setIntroduction($introduction)
283
    {
284
        $this->introduction = $introduction;
285
286
        return $this;
287
    }
288
289
    /**
290
     * @return string
291
     */
292
    public function getBoilerplate(): string
293
    {
294
        return $this->boilerplate;
295
    }
296
297
    /**
298
     * @param string $boilerplate
299
     *
300
     * @return self
301
     */
302
    public function setBoilerplate($boilerplate)
303
    {
304
        $this->boilerplate = $boilerplate;
305
306
        return $this;
307
    }
308
309
310
311
    /**
312
     * @param null $key
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $key is correct as it would always require null to be passed?
Loading history...
313
     * @param null $default
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $default is correct as it would always require null to be passed?
Loading history...
314
     * @param bool $set
315
     * @return null
316
     */
317
    public function get($key = null, $default = null, $set = false)
318
    {
319
        if (isset($this->_freeValues[$key])) {
320
            return $this->_freeValues[$key];
321
        }
322
        if ($set) {
323
            $this->set($key, $default);
324
        }
325
        return $default;
326
    }
327
328
    /**
329
     * @param $key
330
     * @param $value
331
     * @return $this
332
     */
333
    public function set($key, $value)
334
    {
335
        //$this->checkWriteAccess();
336
        $this->_freeValues[$key] = $value;
337
        return $this;
338
    }
339
340
    public function __get($property)
341
    {
342
        $getter = "get" . ucfirst($property);
343
        if (method_exists($this, $getter)) {
344
            return $this->$getter();
345
        }
346
347
        if (property_exists($this, $property)) {
348
            return $this->$property;
349
        }
350
351
        return $this->get($property);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->get($property) targeting Jobs\Entity\TemplateValues::get() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
352
    }
353
354
    public function __set($property, $value)
355
    {
356
        //$this->checkWriteAccess();
357
        $setter = 'set' . ucfirst($property);
358
        if (method_exists($this, $setter)) {
359
            $this->$setter($value);
360
            return;
361
        }
362
363
        if (property_exists($this, $property)) {
364
            $this->$property = $value;
365
            return;
366
        }
367
368
        $this->set($property, $value);
369
    }
370
371
    public function __isset($property)
372
    {
373
        $value = $this->__get($property);
374
375
        if (is_array($value) && !count($value)) {
376
            return false;
377
        }
378
        if (is_bool($value) || is_object($value)) {
379
            return true;
380
        }
381
        return (bool) $value;
382
    }
383
}
384