Completed
Pull Request — master (#1)
by Romain
02:17
created

UserResponse::setProfilePic()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
namespace Kerox\Messenger\Response;
3
4
use Kerox\Messenger\UserInterface;
5
use Psr\Http\Message\ResponseInterface;
6
7
class UserResponse extends AbstractResponse implements UserInterface
8
{
9
10
    /**
11
     * @var null|string
12
     */
13
    protected $firstName;
14
15
    /**
16
     * @var null|string
17
     */
18
    protected $lastName;
19
20
    /**
21
     * @var null|string
22
     */
23
    protected $profilePic;
24
25
    /**
26
     * @var null|string
27
     */
28
    protected $locale;
29
30
    /**
31
     * @var null|int
32
     */
33
    protected $timezone;
34
35
    /**
36
     * @var null|string
37
     */
38
    protected $gender;
39
40
    /**
41
     * @var null|bool
42
     */
43
    protected $isPaymentEnabled;
44
45
    /**
46
     * UserProfileResponse constructor.
47
     *
48
     * @param \Psr\Http\Message\ResponseInterface $response
49
     */
50
    public function __construct(ResponseInterface $response)
51
    {
52
        parent::__construct($response);
53
    }
54
55
    /**
56
     * @param array $response
57
     * @return void
58
     */
59
    protected function parseResponse(array $response)
60
    {
61
        $this->setFirstName($response);
62
        $this->setLastName($response);
63
        $this->setProfilePic($response);
64
        $this->setLocale($response);
65
        $this->setTimezone($response);
66
        $this->setGender($response);
67
        $this->setIsPaymentEnabled($response);
68
    }
69
70
    /**
71
     * @return null|string
72
     */
73
    public function getFirstName()
74
    {
75
        return $this->firstName;
76
    }
77
78
    /**
79
     * @param array $response
80
     * @return void
81
     */
82
    private function setFirstName(array $response)
83
    {
84
        if (isset($response[self::FIRST_NAME])) {
85
            $this->firstName = $response[self::FIRST_NAME];
86
        }
87
    }
88
89
    /**
90
     * @return null|string
91
     */
92
    public function getLastName()
93
    {
94
        return $this->lastName;
95
    }
96
97
    /**
98
     * @param array $response
99
     * @return void
100
     */
101
    private function setLastName(array $response)
102
    {
103
        if (isset($response[self::LAST_NAME])) {
104
            $this->lastName = $response[self::LAST_NAME];
105
        }
106
    }
107
108
    /**
109
     * @return null|string
110
     */
111
    public function getProfilePic()
112
    {
113
        return $this->profilePic;
114
    }
115
116
    /**
117
     * @param array $response
118
     * @return void
119
     */
120
    private function setProfilePic(array $response)
121
    {
122
        if (isset($response[self::PROFILE_PIC])) {
123
            $this->profilePic = $response[self::PROFILE_PIC];
124
        }
125
    }
126
127
    /**
128
     * @return null|string
129
     */
130
    public function getLocale()
131
    {
132
        return $this->locale;
133
    }
134
135
    /**
136
     * @param array $response
137
     * @return void
138
     */
139
    private function setLocale(array $response)
140
    {
141
        if (isset($response[self::LOCALE])) {
142
            $this->locale = $response[self::LOCALE];
143
        }
144
    }
145
146
    /**
147
     * @return int|null
148
     */
149
    public function getTimezone()
150
    {
151
        return $this->timezone;
152
    }
153
154
    /**
155
     * @param array $response
156
     * @return void
157
     */
158
    private function setTimezone(array $response)
159
    {
160
        if (isset($response[self::TIMEZONE])) {
161
            $this->timezone = $response[self::TIMEZONE];
162
        }
163
    }
164
165
    /**
166
     * @return null|string
167
     */
168
    public function getGender()
169
    {
170
        return $this->gender;
171
    }
172
173
    /**
174
     * @param array $response
175
     * @return void
176
     */
177
    private function setGender(array $response)
178
    {
179
        if (isset($response[self::GENDER])) {
180
            $this->gender = $response[self::GENDER];
181
        }
182
    }
183
184
    /**
185
     * @return bool|null
186
     */
187
    public function getIsPaymentEnabled()
188
    {
189
        return $this->isPaymentEnabled;
190
    }
191
192
    /**
193
     * @param array $response
194
     * @return void
195
     */
196
    private function setIsPaymentEnabled(array $response)
197
    {
198
        if (isset($response[self::IS_PAYMENT_ENABLED])) {
199
            $this->isPaymentEnabled = $response[self::IS_PAYMENT_ENABLED];
200
        }
201
    }
202
}
203