Passed
Push — master ( 7116ad...cdfcca )
by Gabor
07:44
created

PolicyEntity::setPolicyId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.2
6
 *
7
 * @copyright 2012 - 2019 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 PolicyEntity
20
 */
21
class PolicyEntity extends AbstractEntity
22
{
23
    /**
24
     * @var array
25
     */
26
    protected $container = [
27
        'id_policy' => null,
28
        'fk_resource' => null,
29
        'fk_application' => null,
30
        'name' => null,
31
        'title' => null,
32
        'description' => null,
33
        'method' => null,
34
        'is_read_only' => null,
35
        'date_created' => null,
36
        'date_modified' => null,
37
    ];
38
39
    /**
40
     * @param int $identifier
41
     * @return PolicyEntity
42
     */
43
    public function setPolicyId(int $identifier) : PolicyEntity
44
    {
45
        $this->container['id_policy'] = $identifier;
46
47
        return $this;
48
    }
49
50
    /**
51
     * @return int|null
52
     */
53
    public function getPolicyId() : ? int
54
    {
55
        return !is_null($this->container['id_policy'])
56
            ? (int) $this->container['id_policy']
57
            : null;
58
    }
59
60
    /**
61
     * @param int $resourceIdentifier
62
     * @return PolicyEntity
63
     */
64
    public function setResourceId(int $resourceIdentifier) : PolicyEntity
65
    {
66
        $this->container['fk_resource'] = $resourceIdentifier;
67
68
        return $this;
69
    }
70
71
    /**
72
     * @return int|null
73
     */
74 2
    public function getResourceId() : ? int
75
    {
76 2
        return !is_null($this->container['fk_resource'])
77 2
            ? (int) $this->container['fk_resource']
78 2
            : null;
79
    }
80
81
    /**
82
     * @param int $applicationIdentifier
83
     * @return PolicyEntity
84
     */
85
    public function setApplicationId(int $applicationIdentifier) : PolicyEntity
86
    {
87
        $this->container['fk_application'] = $applicationIdentifier;
88
89
        return $this;
90
    }
91
92
    /**
93
     * @return int|null
94
     */
95 2
    public function getApplicationId() : ? int
96
    {
97 2
        return !is_null($this->container['fk_application'])
98 2
            ? (int) $this->container['fk_application']
99 2
            : null;
100
    }
101
102
    /**
103
     * @param string $name
104
     * @return PolicyEntity
105
     */
106
    public function setName(string $name) : PolicyEntity
107
    {
108
        $this->container['name'] = $name;
109
110
        return $this;
111
    }
112
113
    /**
114
     * @return null|string
115
     */
116
    public function getName() : ? string
117
    {
118
        return $this->container['name'];
119
    }
120
121
    /**
122
     * @param string $title
123
     * @return PolicyEntity
124
     */
125
    public function setTitle(string $title) : PolicyEntity
126
    {
127
        $this->container['title'] = $title;
128
129
        return $this;
130
    }
131
132
    /**
133
     * @return null|string
134
     */
135
    public function getTitle() : ? string
136
    {
137
        return $this->container['title'];
138
    }
139
140
    /**
141
     * @param string $description
142
     * @return PolicyEntity
143
     */
144
    public function setDescription(string $description) : PolicyEntity
145
    {
146
        $this->container['description'] = $description;
147
148
        return $this;
149
    }
150
151
    /**
152
     * @return null|string
153
     */
154
    public function getDescription() : ? string
155
    {
156
        return $this->container['description'];
157
    }
158
159
    /**
160
     * @param bool $isReadonly
161
     * @return PolicyEntity
162
     */
163
    public function setIsReadOnly(bool $isReadonly) : PolicyEntity
164
    {
165
        $this->container['is_read_only'] = $isReadonly ? 1 : 0;
166
167
        return $this;
168
    }
169
170
    /**
171
     * @return bool
172
     */
173
    public function getIsReadOnly() : bool
174
    {
175
        return !empty($this->container['is_read_only']);
176
    }
177
178
    /**
179
     * @param DateTime $dateTime
180
     * @return PolicyEntity
181
     */
182
    public function setDateCreated(DateTime $dateTime) : PolicyEntity
183
    {
184
        $this->container['date_created'] = $dateTime->format('Y-m-d H:i:s');
185
186
        return $this;
187
    }
188
189
    /**
190
     * @return null|DateTime
191
     */
192
    public function getDateCreated() : ? DateTime
193
    {
194
        return !empty($this->container['date_created'])
195
            ? new DateTime($this->container['date_created'])
196
            : null;
197
    }
198
199
    /**
200
     * @param DateTime $dateTime
201
     * @return PolicyEntity
202
     */
203
    public function setDateModified(DateTime $dateTime) : PolicyEntity
204
    {
205
        $this->container['date_modified'] = $dateTime->format('Y-m-d H:i:s');
206
207
        return $this;
208
    }
209
210
    /**
211
     * @return null|DateTime
212
     */
213
    public function getDateModified() : ? DateTime
214
    {
215
        return !empty($this->container['date_modified'])
216
            ? new DateTime($this->container['date_modified'])
217
            : null;
218
    }
219
}
220