Completed
Push — master ( 3cb300...cba459 )
by Tobias
03:38
created

Statement::setFullPostUrl()   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
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
     * @var string
24
     */
25
    private $sentence;
26
27
    /**
28
     * @var array
29
     */
30
    private $assessments;
31
32
    /**
33
     * @var int
34
     */
35
    private $progress;
36
37
    /**
38
     * @var string
39
     */
40
    private $postUrl;
41
42
    /**
43
     * @var string
44
     */
45
    private $fullPostUrl;
46
47
    /**
48
     * @var string
49
     */
50
    private $section;
51
52
    /**
53
     * @var string
54
     */
55
    private $type;
56
57
    /**
58
     * @param string $id
59
     */
60
    private function __construct($id)
61
    {
62
        $this->id = $id;
63
    }
64
65
    /**
66
     * @param array $data
67
     *
68
     * @return Statement|null
69
     */
70
    public static function createFromArray(array $data)
71
    {
72
        $data = $data['data'];
73
        if (empty($data)) {
74
            return null;
75
        }
76
77
        $statement = new self($data['id']);
78
        $statement->setSentence($data['sentence']);
79
        $statement->setAssessments($data['assessments']);
80
        $statement->setProgress($data['progress']);
81
        $statement->setPostUrl($data['post_url']);
82
        $statement->setFullPostUrl($data['full_post_url']);
83
        $statement->setSection($data['section']);
84
        $statement->setType($data['type']);
85
86
        return $statement;
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getId()
93
    {
94
        return $this->id;
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function getSentence()
101
    {
102
        return $this->sentence;
103
    }
104
105
    /**
106
     * @param string $sentence
107
     */
108
    private function setSentence($sentence)
109
    {
110
        $this->sentence = $sentence;
111
    }
112
113
    /**
114
     * @return array
115
     */
116
    public function getAssessments()
117
    {
118
        return $this->assessments;
119
    }
120
121
    /**
122
     * @param array $assessments
123
     */
124
    private function setAssessments($assessments)
125
    {
126
        $this->assessments = $assessments;
127
    }
128
129
    /**
130
     * @return int
131
     */
132
    public function getProgress()
133
    {
134
        return $this->progress;
135
    }
136
137
    /**
138
     * @param int $progress
139
     */
140
    private function setProgress($progress)
141
    {
142
        $this->progress = $progress;
143
    }
144
145
    /**
146
     * @return string
147
     */
148
    public function getPostUrl()
149
    {
150
        return $this->postUrl;
151
    }
152
153
    /**
154
     * @param string $postUrl
155
     */
156
    private function setPostUrl($postUrl)
157
    {
158
        $this->postUrl = $postUrl;
159
    }
160
161
    /**
162
     * @return string
163
     */
164
    public function getFullPostUrl()
165
    {
166
        return $this->fullPostUrl;
167
    }
168
169
    /**
170
     * @param string $fullPostUrl
171
     */
172
    private function setFullPostUrl($fullPostUrl)
173
    {
174
        $this->fullPostUrl = $fullPostUrl;
175
    }
176
177
    /**
178
     * @return string
179
     */
180
    public function getSection()
181
    {
182
        return $this->section;
183
    }
184
185
    /**
186
     * @param string $section
187
     */
188
    private function setSection($section)
189
    {
190
        $this->section = $section;
191
    }
192
193
    /**
194
     * @return string
195
     */
196
    public function getType()
197
    {
198
        return $this->type;
199
    }
200
201
    /**
202
     * @param string $type
203
     */
204
    private function setType($type)
205
    {
206
        $this->type = $type;
207
    }
208
}
209