Test Failed
Pull Request — master (#1)
by Daniel
05:30
created

Task::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Todo\Domain;
4
5
/**
6
 * Class Task
7
 *
8
 * Task object definition
9
 *
10
 * @category None
11
 * @package  Todo\Domain
12
 * @author   Martin Pham <[email protected]>
13
 * @license  None http://
14
 * @link     None
15
 */
16
class Task implements \JsonSerializable
17
{
18
    /**
19
     * Task's statuses
20
     */
21
    const STATUS_REMAINING = 'remaining';
22
    const STATUS_COMPLETED = 'completed';
23
24
    /**
25
     * Id
26
     *
27
     * @var mixed
28
     */
29
    protected $id;
30
31
    /**
32
     * Name
33
     *
34
     * @var string
35
     */
36
    protected $name;
37
38
    /**
39
     * Status
40
     * We want default Task's status is remaining
41
     *
42
     * @var string
43
     */
44
    protected $status = Task::STATUS_REMAINING;
45
46
    /**
47
     * Created time
48
     *
49
     * @var \DateTime
50
     */
51
    protected $createdAt;
52
53
    /**
54
     * Updated time
55
     *
56
     * @var \DateTime
57
     */
58
    protected $updatedAt;
59
60
    /**
61
     * @param string $name
62
     */
63
    public function __construct(string $name)
64
    {
65
        $this->name = $name;
66
        $this->createdAt = new \DateTime();
67
        $this->status = self::STATUS_REMAINING;
68
    }
69
70
    /**
71
     * Get Id
72
     *
73
     * @return mixed
74
     */
75
    public function getId()
76
    {
77
        return $this->id;
78
    }
79
80
    /**
81
     * Set Id
82
     *
83
     * @param mixed $id Id
84
     */
85
    public function setId($id)
86
    {
87
        $this->id = $id;
88
    }
89
90
    /**
91
     * Get Name
92
     *
93
     * @return mixed
94
     */
95
    public function getName()
96
    {
97
        return $this->name;
98
    }
99
100
    /**
101
     * Set Name
102
     *
103
     * @param mixed $name Name
104
     */
105
    public function setName($name)
106
    {
107
        $this->name = $name;
108
    }
109
110
    /**
111
     * Get Status
112
     *
113
     * @return mixed
114
     */
115
    public function getStatus()
116
    {
117
        return $this->status;
118
    }
119
120
    /**
121
     * Set Status
122
     *
123
     * @param mixed $status Status
124
     */
125
    public function setStatus($status)
126
    {
127
        $this->status = $status;
128
    }
129
130
    /**
131
     * Get CreatedAt
132
     *
133
     * @return mixed
134
     */
135
    public function getCreatedAt()
136
    {
137
        return $this->createdAt;
138
    }
139
140
    /**
141
     * Set CreatedAt
142
     *
143
     * @param mixed $createdAt CreatedAt
144
     */
145
    public function setCreatedAt($createdAt)
146
    {
147
        $this->createdAt = $createdAt;
148
    }
149
150
    /**
151
     * Get UpdatedAt
152
     *
153
     * @return mixed
154
     */
155
    public function getUpdatedAt()
156
    {
157
        return $this->updatedAt;
158
    }
159
160
    /**
161
     * Set UpdatedAt
162
     *
163
     * @param mixed $updatedAt UpdatedAt
164
     */
165
    public function setUpdatedAt($updatedAt)
166
    {
167
        $this->updatedAt = $updatedAt;
168
    }
169
170
    /**
171
     * @inheritDoc
172
     */
173
    public function jsonSerialize()
174
    {
175
        return [
176
            'id' => $this->getId(),
177
            'name' => $this->getName(),
178
            'status' => $this->getStatus()
179
        ];
180
    }
181
}
182