Passed
Push — master ( 56d79f...0f1631 )
by Peter
02:35
created

BlockLayout::toData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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