Test Failed
Branch lab/data (a414ec)
by Gabor
07:41
created

ResourceEntity::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.1
6
 *
7
 * @copyright 2012 - 2018 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Data\Entity;
15
16
use WebHemi\DateTime;
17
18
/**
19
 * Class ResourceEntity
20
 */
21
class ResourceEntity extends AbstractEntity
22
{
23
    /**
24
     * @var array
25
     */
26
    protected $container = [
27
        'id_resource' => null,
28
        'name' => null,
29
        'title' => null,
30
        'description' => null,
31
        'type' => null,
32
        'is_read_only' => null,
33
        'date_created' => null,
34
        'date_modified' => null,
35
    ];
36
37
    /**
38
     * @param int $identifier
39
     * @return ResourceEntity
40
     */
41
    public function setResourceId(int $identifier) : ResourceEntity
42
    {
43
        $this->container['id_resource'] = $identifier;
44
45
        return $this;
46
    }
47
48
    /**
49
     * @return int|null
50
     */
51
    public function getResourceId() : ? int
52
    {
53
        return !is_null($this->container['id_resource'])
54
            ? (int) $this->container['id_resource']
55
            : null;
56
    }
57
58
    /**
59
     * @param string $name
60
     * @return ResourceEntity
61
     */
62
    public function setName(string $name) : ResourceEntity
63
    {
64
        $this->container['name'] = $name;
65
66
        return $this;
67
    }
68
69
    /**
70
     * @return null|string
71
     */
72
    public function getName() : ? string
73
    {
74
        return $this->container['name'];
75
    }
76
77
    /**
78
     * @param string $title
79
     * @return ResourceEntity
80
     */
81
    public function setTitle(string $title) : ResourceEntity
82
    {
83
        $this->container['title'] = $title;
84
85
        return $this;
86
    }
87
88
    /**
89
     * @return null|string
90
     */
91
    public function getTitle() : ? string
92
    {
93
        return $this->container['title'];
94
    }
95
96
    /**
97
     * @param string $description
98
     * @return ResourceEntity
99
     */
100
    public function setDescription(string $description) : ResourceEntity
101
    {
102
        $this->container['description'] = $description;
103
104
        return $this;
105
    }
106
107
    /**
108
     * @return null|string
109
     */
110
    public function getDescription() : ? string
111
    {
112
        return $this->container['description'];
113
    }
114
115
    /**
116
     * @param string $type
117
     * @return ResourceEntity
118
     */
119
    public function setType(string $type) : ResourceEntity
120
    {
121
        $this->container['type'] = $type;
122
123
        return $this;
124
    }
125
126
    /**
127
     * @return null|string
128
     */
129
    public function getType() : ? string
130
    {
131
        return $this->container['type'];
132
    }
133
134
    /**
135
     * @param bool $isReadonly
136
     * @return ResourceEntity
137
     */
138
    public function setIsReadOnly(bool $isReadonly) : ResourceEntity
139
    {
140
        $this->container['is_read_only'] = $isReadonly ? 1 : 0;
141
142
        return $this;
143
    }
144
145
    /**
146
     * @return bool
147
     */
148
    public function getIsReadOnly() : bool
149
    {
150
        return !empty($this->container['is_read_only']);
151
    }
152
153
    /**
154
     * @param DateTime $dateTime
155
     * @return ResourceEntity
156
     */
157
    public function setDateCreated(DateTime $dateTime) : ResourceEntity
158
    {
159
        $this->container['date_created'] = $dateTime->format('Y-m-d H:i:s');
160
161
        return $this;
162
    }
163
164
    /**
165
     * @return null|DateTime
166
     */
167
    public function getDateCreated() : ? DateTime
168
    {
169
        return !empty($this->container['date_created'])
170
            ? new DateTime($this->container['date_created'])
171
            : null;
172
    }
173
174
    /**
175
     * @param DateTime $dateTime
176
     * @return ResourceEntity
177
     */
178
    public function setDateModified(DateTime $dateTime) : ResourceEntity
179
    {
180
        $this->container['date_modified'] = $dateTime->format('Y-m-d H:i:s');
181
182
        return $this;
183
    }
184
185
    /**
186
     * @return null|DateTime
187
     */
188
    public function getDateModified() : ? DateTime
189
    {
190
        return !empty($this->container['date_modified'])
191
            ? new DateTime($this->container['date_modified'])
192
            : null;
193
    }
194
}
195