Completed
Push — master ( 7b6a9e...621ea2 )
by Nick
15:23
created

Slot::getValue()   A

Complexity

Conditions 2
Paths 2

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 2
eloc 2
nc 2
nop 2
1
<?php
2
3
namespace Acquia\LiftClient\Entity;
4
5
use DateTime;
6
7
class Slot extends \ArrayObject
8
{
9
    use EntityTrait;
10
11
    /**
12
     * @param array $array
13
     */
14
    public function __construct(array $array = [])
15
    {
16
        parent::__construct($array);
17
    }
18
19
    /**
20
     * Sets the 'id' parameter.
21
     *
22
     * @param string $id
23
     *
24
     * @return \Acquia\LiftClient\Entity\Slot
25
     */
26
    public function setId($id)
27
    {
28
        $this['id'] = $id;
29
30
        return $this;
31
    }
32
33
    /**
34
     * Gets the 'id' parameter.
35
     *
36
     * @return string
37
     */
38
    public function getId()
39
    {
40
        return $this->getEntityValue('id', '');
41
    }
42
43
    /**
44
     * Sets the 'label' parameter.
45
     *
46
     * @param string $label
47
     *
48
     * @return \Acquia\LiftClient\Entity\Slot
49
     */
50
    public function setLabel($label)
51
    {
52
        $this['label'] = $label;
53
54
        return $this;
55
    }
56
57
    /**
58
     * Gets the 'id' parameter.
59
     *
60
     * @return string
61
     */
62
    public function getLabel()
63
    {
64
        return $this->getEntityValue('label', '');
65
    }
66
67
    /**
68
     * Sets the 'description' parameter.
69
     *
70
     * @param string $description
71
     *
72
     * @return \Acquia\LiftClient\Entity\Slot
73
     */
74
    public function setDescription($description)
75
    {
76
        $this['description'] = $description;
77
78
        return $this;
79
    }
80
81
    /**
82
     * Gets the 'description' parameter.
83
     *
84
     * @return string
85
     */
86
    public function getDescription()
87
    {
88
        return $this->getEntityValue('description', '');
89
    }
90
91
    /**
92
     * Sets the 'html' parameter.
93
     *
94
     * @param string $html
95
     *
96
     * @return \Acquia\LiftClient\Entity\Slot
97
     */
98
    public function setHtml($html)
99
    {
100
        $this['html'] = $html;
101
102
        return $this;
103
    }
104
105
    /**
106
     * Gets the 'html' parameter.
107
     *
108
     * @return string
109
     */
110
    public function getHtml()
111
    {
112
        return $this->getEntityValue('html', '');
113
    }
114
115
    /**
116
     * Sets the 'status' parameter.
117
     *
118
     * @param bool $status
119
     *
120
     * @return \Acquia\LiftClient\Entity\Slot
121
     */
122
    public function setStatus($status)
123
    {
124
        if ($status === true) {
125
            $this['status'] = 'enabled';
126
        } else {
127
            $this['status'] = 'disabled';
128
        }
129
130
        return $this;
131
    }
132
133
    /**
134
     * Gets the 'status' parameter.
135
     *
136
     * @return bool
137
     */
138
    public function getStatus()
139
    {
140
        $status = $this->getEntityValue('status', '');
141
        if ($status == 'enabled') {
142
            return true;
143
        }
144
145
        return false;
146
    }
147
148
    /**
149
     * Sets the 'visibility' parameter.
150
     *
151
     * @param \Acquia\LiftClient\Entity\Visibility $visibility
152
     *
153
     * @return \Acquia\LiftClient\Entity\Slot
154
     */
155
    public function setVisibility(Visibility $visibility)
156
    {
157
        // We need to 'normalize' so that we stay with arrays. Annoying stuff.
158
        $this['visibility'] = $visibility->getArrayCopy();
159
160
        return $this;
161
    }
162
163
    /**
164
     * Gets the 'visibility' parameter.
165
     *
166
     * @return string
167
     */
168
    public function getVisibility()
169
    {
170
        $visibility = $this->getEntityValue('visibility', '');
171
172
        return new \Acquia\LiftClient\Entity\Visibility($visibility);
173
    }
174
175
    /**
176
     * Gets the 'created' parameter.
177
     *
178
     * @return DateTime
179
     */
180
    public function getCreated()
181
    {
182
        $date = $this->getEntityValue('created', '');
183
        $datetime = DateTime::createFromFormat(DateTime::ISO8601, $date);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The expression \DateTime::createFromFor...eTime::ISO8601, $date); of type DateTime|false adds false to the return on line 185 which is incompatible with the return type documented by Acquia\LiftClient\Entity\Slot::getCreated of type DateTime. It seems like you forgot to handle an error condition.
Loading history...
184
185
        return $datetime;
186
    }
187
188
    /**
189
     * Gets the 'updated' parameter.
190
     *
191
     * @return DateTime
192
     */
193
    public function getUpdated()
194
    {
195
        $date = $this->getEntityValue('updated', '');
196
        $datetime = DateTime::createFromFormat(DateTime::ISO8601, $date);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The expression \DateTime::createFromFor...eTime::ISO8601, $date); of type DateTime|false adds false to the return on line 198 which is incompatible with the return type documented by Acquia\LiftClient\Entity\Slot::getUpdated of type DateTime. It seems like you forgot to handle an error condition.
Loading history...
197
198
        return $datetime;
199
    }
200
}
201