Completed
Pull Request — master (#39)
by
unknown
02:27
created

ArticleEntity::exchangeArray()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
namespace Admin\Model\Entity;
4
5
use Zend\Stdlib\ArraySerializableInterface;
6
7
/**
8
 * Class ArticleEntity.
9
 * @package Admin\Model\Entity
10
 */
11
class ArticleEntity implements ArraySerializableInterface
12
{
13
    const TYPE_STANDARD = 1;
14
15
    const STATUS_UNPUBLISHED = 0;
16
    const STATUS_PUBLISHED = 1;
17
18
    /**
19
     * @var string
20
     */
21
    private $article_uuid;
22
23
    /**
24
     * @var string
25
     */
26
    private $title;
27
28
    /**
29
     * @var string
30
     */
31
    private $slug;
32
33
    /**
34
     * @var string
35
     */
36
    private $body;
37
38
    /**
39
     * @var string
40
     */
41
    private $lead;
42
43
    /**
44
     * @var integer
45
     */
46
    private $type = self::TYPE_STANDARD;
47
48
    /**
49
     * @var \DateTime
50
     */
51
    private $created_at;
52
53
    /**
54
     * @var \DateTime
55
     */
56
    private $published_at;
57
58
    /**
59
     * @var integer
60
     */
61
    private $status;
62
63
    /**
64
     * @var integer
65
     */
66
    private $user_uuid = 1;
67
68
    /**
69
     * @inheritdoc
70
     *
71
     * @param array $array
72
     */
73
    public function exchangeArray(array $array)
74
    {
75
        foreach ($array as $key => $value) {
76
            $setter = 'set' . ucfirst($key);
77
78
            if (method_exists($this, $setter)) {
79
                $this->{$setter}($value);
80
            }
81
        }
82
    }
83
84
    /**
85
     * @inheritdoc
86
     *
87
     * @return array
88
     */
89
    public function getArrayCopy()
90
    {
91
        $data = [];
92
93
        foreach (get_object_vars($this) as $key => $value) {
94
            $data[$key] = $value;
95
        }
96
97
        return $data;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getArticle_uuid()
104
    {
105
        return bin2hex($this->article_uuid);
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getTitle()
112
    {
113
        return $this->title;
114
    }
115
116
    /**
117
     * @return string
118
     */
119
    public function getSlug()
120
    {
121
        return $this->slug;
122
    }
123
124
    /**
125
     * @return string
126
     */
127
    public function getBody()
128
    {
129
        return $this->body;
130
    }
131
132
    /**
133
     * @return string
134
     */
135
    public function getLead()
136
    {
137
        return $this->lead;
138
    }
139
140
    /**
141
     * @return int
142
     */
143
    public function getType()
144
    {
145
        return $this->type;
146
    }
147
148
    /**
149
     * @return \DateTime
150
     */
151
    public function getCreated_at()
152
    {
153
        return $this->created_at;
154
    }
155
156
    /**
157
     * @return \DateTime
158
     */
159
    public function getPublished_at()
160
    {
161
        return $this->published_at;
162
    }
163
164
    /**
165
     * @return int
166
     */
167
    public function getStatus()
168
    {
169
        return $this->status;
170
    }
171
172
    /**
173
     * @return int
174
     */
175
    public function getUser_uuid()
176
    {
177
        return $this->user_uuid;
178
    }
179
180
    /**
181
     * @param string $articleUuid
182
     */
183
    private function setArticle_uuid($articleUuid)
184
    {
185
        $this->article_uuid = $articleUuid;
186
    }
187
188
    /**
189
     * @param string $title
190
     */
191
    private function setTitle($title)
192
    {
193
        $this->title = $title;
194
        $this->setSlug($title);
195
    }
196
197
    /**
198
     * @param string $slug
199
     */
200
    private function setSlug($slug)
201
    {
202
        $this->slug = urlencode($slug);
203
    }
204
205
    /**
206
     * @param string $body
207
     */
208
    private function setBody($body)
209
    {
210
        $this->body = $body;
211
    }
212
213
    /**
214
     * @param string $lead
215
     */
216
    private function setLead($lead)
217
    {
218
        $this->lead = $lead;
219
    }
220
221
    /**
222
     * @param int $type
223
     */
224
    private function setType($type)
225
    {
226
        $this->type = $type;
227
    }
228
229
    /**
230
     * @param \DateTime $createdAt
231
     */
232
    private function setCreated_at($createdAt)
233
    {
234
        $this->created_at = $createdAt;
235
    }
236
237
    /**
238
     * @param \DateTime $publishedAt
239
     */
240
    private function setPublished_at($publishedAt)
241
    {
242
        $this->published_at = $publishedAt;
243
    }
244
245
    /**
246
     * @param int $status
247
     */
248
    private function setStatus($status)
249
    {
250
        $this->status = $status;
251
    }
252
253
    /**
254
     * @param int $userUuid
255
     */
256
    private function setUser_uuid($userUuid)
257
    {
258
        $this->user_uuid = $userUuid;
259
    }
260
}