Completed
Push — master ( 658521...37ea28 )
by Tobias
02:32
created

Statement::getImage()   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 Happyr\ApiClient\Model\Statement;
4
5
use Happyr\ApiClient\Model\CreatableFromArray;
6
7
/**
8
 * @author Tobias Nyholm <[email protected]>
9
 */
10
final class Statement implements CreatableFromArray
11
{
12
    const TYPE_STRING = 'string';
13
    const TYPE_IMAGE = 'image';
14
    const SECTION_PERSONALITY = 'personality';
15
    const SECTION_INTELLIGENCE = 'intelligence';
16
17
    /**
18
     * @var string
19
     */
20
    private $id;
21
22
    /**
23
     * Has a value if $type="text"
24
     * @var string|null
25
     */
26
    private $sentence;
27
28
    /**
29
     * Has a value if $type="image"
30
     * @var string|null
31
     */
32
    private $image;
33
34
    /**
35
     * @var array
36
     */
37
    private $assessments;
38
39
    /**
40
     * @var int
41
     */
42
    private $progress;
43
44
    /**
45
     * @var string
46
     */
47
    private $postUrl;
48
49
    /**
50
     * @var string
51
     */
52
    private $fullPostUrl;
53
54
    /**
55
     * @var string
56
     */
57
    private $section;
58
59
    /**
60
     * @var string
61
     */
62
    private $type;
63
64
    /**
65
     * @param string $id
66
     */
67
    private function __construct($id)
68
    {
69
        $this->id = $id;
70
    }
71
72
    /**
73
     * @param array $data
74
     *
75
     * @return Statement|null
76
     */
77
    public static function createFromArray(array $data)
78
    {
79
        $data = $data['data'];
80
        if (empty($data)) {
81
            return null;
82
        }
83
84
        $statement = new self($data['id']);
85
        $statement->setSentence(isset($data['sentence']) ? $data['sentence'] : null);
86
        $statement->setImage(isset($data['image']) ? $data['image'] : null);
87
        $statement->setAssessments($data['assessments']);
88
        $statement->setProgress($data['progress']);
89
        $statement->setPostUrl($data['post_url']);
90
        $statement->setFullPostUrl($data['full_post_url']);
91
        $statement->setSection($data['section']);
92
        $statement->setType($data['type']);
93
94
        return $statement;
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function getId()
101
    {
102
        return $this->id;
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    public function getSentence()
109
    {
110
        return $this->sentence;
111
    }
112
113
    /**
114
     * @param string $sentence
115
     */
116
    private function setSentence($sentence)
117
    {
118
        $this->sentence = $sentence;
119
    }
120
121
    /**
122
     * @return null|string
123
     */
124
    public function getImage()
125
    {
126
        return $this->image;
127
    }
128
129
    /**
130
     * @param null|string $image
131
     */
132
    public function setImage($image)
133
    {
134
        $this->image = $image;
135
    }
136
137
    /**
138
     * @return array
139
     */
140
    public function getAssessments()
141
    {
142
        return $this->assessments;
143
    }
144
145
    /**
146
     * @param array $assessments
147
     */
148
    private function setAssessments($assessments)
149
    {
150
        $this->assessments = $assessments;
151
    }
152
153
    /**
154
     * @return int
155
     */
156
    public function getProgress()
157
    {
158
        return $this->progress;
159
    }
160
161
    /**
162
     * @param int $progress
163
     */
164
    private function setProgress($progress)
165
    {
166
        $this->progress = $progress;
167
    }
168
169
    /**
170
     * @return string
171
     */
172
    public function getPostUrl()
173
    {
174
        return $this->postUrl;
175
    }
176
177
    /**
178
     * @param string $postUrl
179
     */
180
    private function setPostUrl($postUrl)
181
    {
182
        $this->postUrl = $postUrl;
183
    }
184
185
    /**
186
     * @return string
187
     */
188
    public function getFullPostUrl()
189
    {
190
        return $this->fullPostUrl;
191
    }
192
193
    /**
194
     * @param string $fullPostUrl
195
     */
196
    private function setFullPostUrl($fullPostUrl)
197
    {
198
        $this->fullPostUrl = $fullPostUrl;
199
    }
200
201
    /**
202
     * @return string
203
     */
204
    public function getSection()
205
    {
206
        return $this->section;
207
    }
208
209
    /**
210
     * @param string $section
211
     */
212
    private function setSection($section)
213
    {
214
        $this->section = $section;
215
    }
216
217
    /**
218
     * @return string
219
     */
220
    public function getType()
221
    {
222
        return $this->type;
223
    }
224
225
    /**
226
     * @param string $type
227
     */
228
    private function setType($type)
229
    {
230
        $this->type = $type;
231
    }
232
}
233