Passed
Push — master ( 80fed1...32ef61 )
by Peter
09:46
created

AdminResource::getIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
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 array|null
75
     */
76
    public function toData(): ?array
77
    {
78
        return [
79
            "id"         => $this->getId(),
80
            "identifier" => $this->getIdentifier(),
81
        ];
82
    }
83
84
    /**
85
     * @return string
86
     */
87
    public function toJSON(): string
88
    {
89
        return json_encode($this->toData());
90
    }
91
}
92