Completed
Push — master ( c0d451...eab989 )
by Tyler
02:24 queued 01:00
created

Plivo::applyResponse()   B

Complexity

Conditions 6
Paths 20

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 11.3413

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 8
cts 17
cp 0.4706
rs 8.8571
c 0
b 0
f 0
cc 6
eloc 11
nc 20
nop 1
crap 11.3413
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
            $this->numbers = collect($response['available_phone_numbers'])->pluck("phone_number")->all();
23 3
        }
24
25 3
        if (isset($response['status'])) {
26
            $this->status = $response["status"];
27
        }
28 3
    }
29
30
    public function successful()
31
    {
32
        return $this->status >= 200 && $this->status < 300;
33
    }
34
}
35