Completed
Push — master ( e2547a...b91078 )
by Tyler
04:34
created

Plivo::applyResponse()   B

Complexity

Conditions 6
Paths 20

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 12.4072

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 7
cts 16
cp 0.4375
rs 8.8571
c 0
b 0
f 0
cc 6
eloc 10
nc 20
nop 1
crap 12.4072
1
<?php
2
3
namespace LeadThread\Sms\Responses;
4
5
use LeadThread\Sms\Interfaces\SmsResponse;
6
7
class Plivo extends Response
8
{
9 3
    public function applyResponse($response)
10
    {
11 3
        if (isset($response['response'])) {
12
            if (isset($response['response']['error'])) {
13
                $this->error = $response['response']['error'];
14
            }
15
            if (isset($response['response']['message_uuid'])) {
16
                $this->uuid = $response['response']['message_uuid'][0];
17
            }
18
        }
19
20 3
        if (isset($response['available_phone_numbers'])) {
21 3
            $this->number = $response['available_phone_numbers'][0]['phone_number'];
22 3
        }
23
24 3
        if (isset($response['status'])) {
25
            $this->status = $response["status"];
26
        }
27 3
    }
28
29
    public function successful()
30
    {
31
        return $this->status >= 200 && $this->status < 300;
32
    }
33
}
34