Language   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 91
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setLocale() 0 6 1
A getLocale() 0 4 1
A setDefault() 0 6 1
A isDefault() 0 4 1
A getTitle() 0 4 1
A setTitle() 0 6 1
1
<?php
2
3
namespace Webcook\Cms\I18nBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Webcook\Cms\CoreBundle\Base\BasicEntity;
7
use ApiPlatform\Core\Annotation\ApiResource;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * Language entity used for translations and routing.
12
 *
13
 * @ORM\Entity
14
 * @ORM\Table(name="Language")
15
 * @ApiResource
16
 */
17
class Language extends BasicEntity
18
{
19
    /**
20
     * @ORM\Column(name="title", type="string", length=55)
21
     * @Assert\NotBlank
22
     * @Assert\NotNull
23
     */
24
    private $title;
25
26
    /**
27
     * @ORM\Column(name="locale", type="string", length=2)
28
     * @Assert\NotBlank
29
     * @Assert\NotNull
30
     */
31
    private $locale;
32
33
    /** @ORM\Column(name="isDefault", type="boolean") */
34
    private $default = false;
35
36
    /**
37
     * Set locale of a language.
38
     *
39
     * @param String $locale locale of a language.
40
     *
41
     * @return Language Returns self.
42
     */
43 14
    public function setLocale($locale)
44
    {
45 14
        $this->locale = $locale;
46
47 14
        return $this;
48
    }
49
50
    /**
51
     * Get locale.
52
     *
53
     * @return String Returns locale of language.
54
     */
55 14
    public function getLocale()
56
    {
57 14
        return $this->locale;
58
    }
59
60
    /**
61
     * Set whether language is default or not.
62
     *
63
     * @param String $default Default of a language.
64
     *
65
     * @return Language Returns self.
66
     */
67 14
    public function setDefault($default)
68
    {
69 14
        $this->default = $default;
0 ignored issues
show
Documentation Bug introduced by
The property $default was declared of type boolean, but $default is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
70
71 14
        return $this;
72
    }
73
74
    /**
75
     * Get whether language is default or not.
76
     *
77
     * @return boolean Returns if language is default.
78
     */
79 4
    public function isDefault()
80
    {
81 4
        return $this->default;
82
    }
83
84
    /**
85
     * Gets the value of title.
86
     *
87
     * @return mixed
88
     */
89 4
    public function getTitle()
90
    {
91 4
        return $this->title;
92
    }
93
94
    /**
95
     * Sets the value of title.
96
     *
97
     * @param string $title the title
98
     *
99
     * @return self
100
     */
101 14
    public function setTitle($title)
102
    {
103 14
        $this->title = $title;
104
105 14
        return $this;
106
    }
107
}
108