SmsUpResponse   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
c 2
b 0
f 0
dl 0
loc 64
rs 10
wmc 9

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorId() 0 3 1
A getErrorMsg() 0 3 1
A getResult() 0 3 1
A __construct() 0 8 5
A getStatus() 0 3 1
1
<?php
2
3
namespace SquareetLabs\LaravelSmsUp;
4
5
/**
6
 * Class SmsUpResponse
7
 * @package SquareetLabs\LaravelSmsUp
8
 */
9
class SmsUpResponse
10
{
11
    /**
12
     * @var string
13
     */
14
    private $status;
15
16
    /**
17
     * @var array
18
     */
19
    private $result;
20
21
    /**
22
     * @var string
23
     */
24
    private $errorId;
25
26
    /**
27
     * @var string
28
     */
29
    private $errorMsg;
30
31
    public function __construct(array $response)
32
    {
33
        $this->status = $response['status'];
34
        $this->errorId = isset($response['error_id']) ? $response['error_id'] : '';
35
        $this->errorMsg = isset($response['error_msg']) ? $response['error_msg'] : '';
36
        foreach ($response['result'] as $responseMessage) {
37
            if (array_key_exists('status', $response)) {
38
                $this->result[] = new SmsUpResponseMessage($responseMessage);
39
            }
40
        }
41
    }
42
43
    /**
44
     * @return string|null
45
     */
46
    public function getStatus()
47
    {
48
        return $this->status;
49
    }
50
51
    /**
52
     * @return array
53
     */
54
    public function getResult()
55
    {
56
        return $this->result;
57
    }
58
59
    /**
60
     * @return string|null
61
     */
62
    public function getErrorId()
63
    {
64
        return $this->errorId;
65
    }
66
67
    /**
68
     * @return string|null
69
     */
70
    public function getErrorMsg()
71
    {
72
        return $this->errorMsg;
73
    }
74
}