Completed
Push — master ( 3d485f...407dff )
by Paweł
66:49
created

Revision::setPublishedAt()   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 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Publisher Revision Component.
7
 *
8
 * Copyright 2017 Sourcefabric z.u. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2015 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Component\Revision\Model;
18
19
/**
20
 * Class Revision.
21
 */
22
class Revision implements RevisionInterface
23
{
24
    /**
25
     * @var \DateTime
26
     */
27
    protected $createdAt;
28
29
    /**
30
     * @var \DateTime
31
     */
32
    protected $updatedAt;
33
34
    /**
35
     * @var \DateTime
36
     */
37
    protected $publishedAt;
38
39
    /**
40
     * @var bool
41
     */
42
    protected $isActive;
43
44
    /**
45
     * @var RevisionInterface
46
     */
47
    protected $previous;
48
49
    /**
50
     * @var string
51
     */
52
    protected $status;
53
54
    /**
55
     * @var
56
     */
57
    protected $uniqueKey;
58
59
    /**
60
     * Revision constructor.
61
     */
62
    public function __construct()
63
    {
64
        $this->setUniqueKey(md5(serialize($this->updatedAt).random_bytes(10)));
65
        $this->setIsActive(true);
66
        $this->setStatus(self::STATE_NEW);
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function getStatus(): string
73
    {
74
        return $this->status;
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function setStatus(string $status)
81
    {
82
        $this->status = $status;
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function getUniqueKey()
89
    {
90
        return $this->uniqueKey;
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function setUniqueKey($uniqueKey)
97
    {
98
        $this->uniqueKey = $uniqueKey;
99
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104
    public function getCreatedAt(): \DateTime
105
    {
106
        return $this->createdAt;
107
    }
108
109
    /**
110
     * {@inheritdoc}
111
     */
112
    public function setCreatedAt(\DateTime $createdAt)
113
    {
114
        $this->createdAt = $createdAt;
115
    }
116
117
    /**
118
     * {@inheritdoc}
119
     */
120
    public function getUpdatedAt(): \DateTime
121
    {
122
        return $this->updatedAt;
123
    }
124
125
    /**
126
     * {@inheritdoc}
127
     */
128
    public function setUpdatedAt(\DateTime $updatedAt)
129
    {
130
        $this->updatedAt = $updatedAt;
131
    }
132
133
    /**
134
     * {@inheritdoc}
135
     */
136
    public function getPublishedAt(): \DateTime
137
    {
138
        return $this->publishedAt;
139
    }
140
141
    /**
142
     * {@inheritdoc}
143
     */
144
    public function setPublishedAt(\DateTime $publishedAt)
145
    {
146
        $this->publishedAt = $publishedAt;
147
    }
148
149
    /**
150
     * {@inheritdoc}
151
     */
152
    public function isIsActive(): bool
153
    {
154
        return $this->isActive;
155
    }
156
157
    /**
158
     * {@inheritdoc}
159
     */
160
    public function setIsActive(bool $isActive)
161
    {
162
        $this->isActive = $isActive;
163
    }
164
165
    /**
166
     * {@inheritdoc}
167
     */
168
    public function setPrevious(RevisionInterface $revision)
169
    {
170
        $this->previous = $revision;
171
    }
172
173
    /**
174
     * {@inheritdoc}
175
     */
176
    public function getPrevious()
177
    {
178
        return $this->previous;
179
    }
180
}
181