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

AdminResource::toJSON()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
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 AdminResource implements IStringerEntity
10
{
11
    /** @var string */
12
    protected $id;
13
14
    /** @var string */
15
    protected $identifier;
16
17
    /**
18
     * Block constructor.
19
     *
20
     * @param string $id
21
     * @param string $identifier
22
     */
23
    public function __construct(string $id, string $identifier)
24
    {
25
        $this->id         = $id;
26
        $this->identifier = $identifier;
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function getId()
33
    {
34
        return $this->id;
35
    }
36
37
    /**
38
     * @param string $id
39
     */
40
    public function setId($id)
41
    {
42
        $this->id = $id;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getIdentifier(): string
49
    {
50
        return $this->identifier;
51
    }
52
53
    /**
54
     * @param string $identifier
55
     *
56
     * @return $this
57
     */
58
    public function setIdentifier(string $identifier): AdminResource
59
    {
60
        $this->identifier = $identifier;
61
62
        return $this;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function __toString(): string
69
    {
70
        return $this->getIdentifier();
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function toJSON(): string
77
    {
78
        return json_encode(
79
            [
80
                "id"         => $this->getId(),
81
                "identifier" => $this->getIdentifier(),
82
            ]
83
        );
84
    }
85
}
86