Passed
Push — master ( b37186...7c51ba )
by Peter
04:28
created

UserLanguage::toJSON()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Admin\Domain\Entities;
6
7
use AbterPhp\Framework\Domain\Entities\IStringerEntity;
8
9
class UserLanguage implements IStringerEntity
10
{
11
    /** @var string */
12
    protected $id;
13
14
    /** @var string */
15
    protected $identifier;
16
17
    /** @var string */
18
    protected $name;
19
20
    /**
21
     * Page constructor.
22
     *
23
     * @param string $id
24
     * @param string $identifier
25
     * @param string $name
26
     */
27
    public function __construct(string $id, string $identifier, string $name)
28
    {
29
        $this->id         = $id;
30
        $this->identifier = $identifier;
31
        $this->name       = $name;
32
    }
33
34
    /**
35
     * @return string
36
     */
37
    public function getId()
38
    {
39
        return $this->id;
40
    }
41
42
    /**
43
     * @param string $id
44
     */
45
    public function setId($id)
46
    {
47
        $this->id = $id;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getIdentifier(): string
54
    {
55
        return $this->identifier;
56
    }
57
58
    /**
59
     * @param string $identifier
60
     *
61
     * @return $this
62
     */
63
    public function setIdentifier(string $identifier): UserLanguage
64
    {
65
        $this->identifier = $identifier;
66
67
        return $this;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getName(): string
74
    {
75
        return $this->name;
76
    }
77
78
    /**
79
     * @param string $name
80
     *
81
     * @return $this
82
     */
83
    public function setName(string $name): UserLanguage
84
    {
85
        $this->name = $name;
86
87
        return $this;
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function __toString(): string
94
    {
95
        return $this->getIdentifier();
96
    }
97
98
    /**
99
     * @return string
100
     */
101
    public function toJSON(): string
102
    {
103
        return json_encode(
104
            [
105
                "id"         => $this->getId(),
106
                "identifier" => $this->getIdentifier(),
107
                "name"       => $this->getName(),
108
            ]
109
        );
110
    }
111
}
112