Completed
Push — develop ( 82bf6e...62da87 )
by
unknown
08:42
created

TemplateValues::getHtml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
 * })
28
 * @since 0.29 Adds html field.
29
 */
30
class TemplateValues extends AbstractEntity implements TemplateValuesInterface
0 ignored issues
show
Coding Style introduced by
The property $_freeValues is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
31
{
32
33
    /**
34
     * Qualification field of the job template
35
     *
36
     * @var String
37
     * @ODM\Field(type="string")
38
     */
39
    protected $qualifications='';
40
41
    /**
42
     * Requirements field of the job template
43
     *
44
     * @var String
45
     * @ODM\Field(type="string")
46
     */
47
    protected $requirements='';
48
49
    /**
50
     * Benefits field of the job template
51
     *
52
     * @var String
53
     * @ODM\Field(type="string")
54
     */
55
    protected $benefits='';
56
57
    /**
58
     * Job title field of the job template
59
     *
60
     * @var String
61
     * @ODM\Field(type="string")
62
     */
63
    protected $title='';
64
65
    /**
66
     * Company description field of the job template
67
     *
68
     * @var String
69
     * @ODM\Field(type="string")
70
     */
71
    protected $description='';
72
73
    /**
74
     * language of the job template values. Must be a valid ISO 639-1 code
75
     *
76
     * @var String
77
     * @ODM\Field(type="string")
78
     */
79
    protected $language='en';
80
81
    /**
82
     * Pure HTML
83
     *
84
     * @ODM\Field(type="string")
85
     * @var string
86
     * @since 0.29
87
     */
88
    protected $html='';
89
90
    /**
91
     * free values (currently not in use)
92
     *
93
     * @ODM\Hash
94
     */
95
    protected $_freeValues;
0 ignored issues
show
Coding Style introduced by
$_freeValues does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
96
97
    /**
98
     * Sets the Qualification field of the job template
99
     *
100
     * @param $qualifications
101
     * @return $this
102
     */
103
    public function setQualifications($qualifications)
104
    {
105
        $this->qualifications= (string) $qualifications;
106
        return $this;
107
    }
108
109
    /**
110
     * Gets the qualification of a job template
111
     *
112
     * @return String
113
     */
114
    public function getQualifications()
115
    {
116
        return $this->qualifications;
117
    }
118
119
    /**
120
     * Sets the requirements of a job template
121
     *
122
     * @param String $requirements
123
     * @return $this
124
     */
125
    public function setRequirements($requirements)
126
    {
127
        $this->requirements=(string) $requirements;
128
        return $this;
129
    }
130
131
    /**
132
     * Gets the requirements of a job template
133
     *
134
     * @return String
135
     */
136
    public function getRequirements()
137
    {
138
        return $this->requirements;
139
    }
140
141
    /**
142
     * Sets the benefits of a job template
143
     *
144
     * @param String $benefits
145
     * @return $this
146
     */
147
    public function setBenefits($benefits)
148
    {
149
        $this->benefits=(string) $benefits;
150
        return $this;
151
    }
152
153
    /**
154
     * Gets the Benefits of a job template
155
     *
156
     * @return String
157
     */
158
    public function getBenefits()
159
    {
160
        return $this->benefits;
161
    }
162
163
    /**
164
     * Sets the job title of the job template
165
     *
166
     * @param $title
167
     * @return $this
168
     */
169
    public function setTitle($title)
170
    {
171
        $this->title=(string) $title;
172
        return $this;
173
    }
174
175
    /**
176
     * Gets the job title of the job template
177
     *
178
     * @return String
179
     */
180
    public function getTitle()
181
    {
182
        return $this->title;
183
    }
184
185
    /**
186
     * Sets the company description of the job template
187
     *
188
     * @param $description
189
     * @return $this
190
     */
191
    public function setDescription($description)
192
    {
193
        $this->description=(string) $description;
194
        return $this;
195
    }
196
197
    /**
198
     * Gets the company description of the job template
199
     *
200
     * @return String
201
     */
202
    public function getDescription()
203
    {
204
        return $this->description;
205
    }
206
207
    /**
208
     * Sets the language of the job template values
209
     *
210
     * @param $language
211
     * @return $this
212
     */
213
    public function setLanguage($language)
214
    {
215
        $this->language=(string) $language;
216
        return $this;
217
    }
218
219
    /**
220
     * Gets the language of the job template values
221
     *
222
     * @return String
223
     */
224
    public function getLanguage()
225
    {
226
        return $this->language;
227
    }
228
229
    /**
230
     * @param string $html
231
     *
232
     * @return self
233
     * @since 0.29
234
     */
235
    public function setHtml($html)
236
    {
237
        $this->html = $html;
238
239
        return $this;
240
    }
241
242
    /**
243
     * @return string
244
     * @since 0.29
245
     */
246
    public function getHtml()
247
    {
248
        return $this->html;
249
    }
250
251
252
253
    /**
254
     * @param null $key
255
     * @param null $default
256
     * @param bool $set
257
     * @return null
258
     */
259 View Code Duplication
    public function get($key = null, $default = null, $set = false)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
260
    {
261
        if (isset($this->_freeValues[$key])) {
262
            return $this->_freeValues[$key];
263
        }
264
        if ($set) {
265
            $this->set($key, $default);
266
        }
267
        return $default;
268
    }
269
270
    /**
271
     * @param $key
272
     * @param $value
273
     * @return $this
274
     */
275
    public function set($key, $value)
276
    {
277
        //$this->checkWriteAccess();
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
278
        $this->_freeValues[$key] = $value;
279
        return $this;
280
    }
281
282 View Code Duplication
    public function __get($property)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
283
    {
284
        $getter = "get" . ucfirst($property);
285
        if (method_exists($this, $getter)) {
286
            return $this->$getter();
287
        }
288
289
        if (property_exists($this, $property)) {
290
            return $this->$property;
291
        }
292
293
        return $this->get($property);
294
    }
295
296 View Code Duplication
    public function __set($property, $value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
297
    {
298
        //$this->checkWriteAccess();
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
299
        $setter = 'set' . ucfirst($property);
300
        if (method_exists($this, $setter)) {
301
            $this->$setter($value);
302
            return;
303
        }
304
305
        if (property_exists($this, $property)) {
306
            $this->$property = $value;
307
            return;
308
        }
309
310
        $this->set($property, $value);
311
    }
312
313 View Code Duplication
    public function __isset($property)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
314
    {
315
        $value = $this->__get($property);
316
317
        if (is_array($value) && !count($value)) {
318
            return false;
319
        }
320
        if (is_bool($value) || is_object($value)) {
321
            return true;
322
        }
323
        return (bool) $value;
324
    }
325
}
326