Completed
Push — master ( a2e0ae...ae8fd6 )
by Nick
11:57 queued 08:25
created

Slot::getHtml()   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 0
1
<?php
2
3
namespace Acquia\LiftClient\Entity;
4
5
use Acquia\LiftClient\Exception\LiftSdkException;
6
use DateTime;
7
8
class Slot extends Entity
9
{
10
    /**
11
     * @param array $array
12
     */
13
    public function __construct(array $array = [])
14
    {
15
        parent::__construct($array);
16
    }
17
18
    /**
19
     * Sets the 'id' parameter.
20
     *
21
     * @param string $id
22
     *
23
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
24
     *
25
     * @return \Acquia\LiftClient\Entity\Slot
26
     */
27
    public function setId($id)
28
    {
29
        if (!is_string($id)) {
30
            throw new LiftSdkException('Argument must be an instance of string.');
31
        }
32
        $this['id'] = $id;
33
34
        return $this;
35
    }
36
37
    /**
38
     * Gets the 'id' parameter.
39
     *
40
     * @return string
41
     */
42
    public function getId()
43
    {
44
        return $this->getEntityValue('id', '');
45
    }
46
47
    /**
48
     * Sets the 'label' parameter.
49
     *
50
     * @param string $label
51
     *
52
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
53
     *
54
     * @return \Acquia\LiftClient\Entity\Slot
55
     */
56
    public function setLabel($label)
57
    {
58
        if (!is_string($label)) {
59
            throw new LiftSdkException('Argument must be an instance of string.');
60
        }
61
        $this['label'] = $label;
62
63
        return $this;
64
    }
65
66
    /**
67
     * Gets the 'id' parameter.
68
     *
69
     * @return string
70
     */
71
    public function getLabel()
72
    {
73
        return $this->getEntityValue('label', '');
74
    }
75
76
    /**
77
     * Sets the 'description' parameter.
78
     *
79
     * @param string $description
80
     *
81
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
82
     *
83
     * @return \Acquia\LiftClient\Entity\Slot
84
     */
85
    public function setDescription($description)
86
    {
87
        if (!is_string($description)) {
88
            throw new LiftSdkException('Argument must be an instance of string.');
89
        }
90
        $this['description'] = $description;
91
92
        return $this;
93
    }
94
95
    /**
96
     * Gets the 'description' parameter.
97
     *
98
     * @return string
99
     */
100
    public function getDescription()
101
    {
102
        return $this->getEntityValue('description', '');
103
    }
104
105
    /**
106
     * Sets the 'status' parameter.
107
     *
108
     * @param bool $status
109
     *
110
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
111
     *
112
     * @return \Acquia\LiftClient\Entity\Slot
113
     */
114
    public function setStatus($status)
115
    {
116
        if (!is_bool($status)) {
117
            throw new LiftSdkException('Argument must be an instance of boolean.');
118
        }
119
        if ($status) {
120
            $this['status'] = 'enabled';
121
        } else {
122
            $this['status'] = 'disabled';
123
        }
124
125
        return $this;
126
    }
127
128
    /**
129
     * Gets the 'status' parameter. True if the slot is published. False is it is not.
130
     *
131
     * @return bool
132
     */
133
    public function getStatus()
134
    {
135
        $status = $this->getEntityValue('status', '');
136
        if ($status == 'enabled') {
137
            return true;
138
        }
139
140
        return false;
141
    }
142
143
    /**
144
     * Sets the 'visibility' parameter.
145
     *
146
     * @param \Acquia\LiftClient\Entity\Visibility $visibility
147
     *
148
     * @return \Acquia\LiftClient\Entity\Slot
149
     */
150
    public function setVisibility(Visibility $visibility)
151
    {
152
        // We need to 'normalize' the data.
153
        $this['visibility'] = $visibility->getArrayCopy();
154
155
        return $this;
156
    }
157
158
    /**
159
     * Gets the 'visibility' parameter.
160
     *
161
     * @return Visibility
162
     */
163
    public function getVisibility()
164
    {
165
        $visibility = $this->getEntityValue('visibility', []);
166
167
        return new Visibility($visibility);
168
    }
169
170
    /**
171
     * Gets the 'created' parameter.
172
     *
173
     * @return DateTime|false
174
     */
175
    public function getCreated()
176
    {
177
        $date = $this->getEntityValue('created', '');
178
        // The ISO8601 DateTime format is not compatible with ISO-8601, but is left this way for backward compatibility
179
        // reasons. Use DateTime::ATOM or DATE_ATOM for compatibility with ISO-8601 instead.
180
        // See http://php.net/manual/en/class.datetime.php
181
        $datetime = DateTime::createFromFormat(DateTime::ATOM, $date);
182
183
        return $datetime;
184
    }
185
186
    /**
187
     * Gets the 'updated' parameter.
188
     *
189
     * @return DateTime|false
190
     */
191
    public function getUpdated()
192
    {
193
        $date = $this->getEntityValue('updated', '');
194
        // The ISO8601 DateTime format is not compatible with ISO-8601, but is left this way for backward compatibility
195
        // reasons. Use DateTime::ATOM or DATE_ATOM for compatibility with ISO-8601 instead.
196
        // See http://php.net/manual/en/class.datetime.php
197
        $datetime = DateTime::createFromFormat(DateTime::ATOM, $date);
198
199
        return $datetime;
200
    }
201
}
202