Completed
Push — master ( b3f24e...84a5c5 )
by Tobias
03:15
created

ShowResponse   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 0
dl 0
loc 109
ccs 0
cts 33
cp 0
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A create() 0 16 4
A getAddress() 0 4 1
A getCode() 0 4 1
A setCode() 0 4 1
A getError() 0 4 1
A setError() 0 4 1
A getCreatedAt() 0 4 1
A setCreatedAt() 0 4 1
1
<?php
2
3
/*
4
 * Copyright (C) 2013-2016 Mailgun
5
 *
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Mailgun\Model\Suppression\Bounce;
11
12
use Mailgun\Model\ApiResponse;
13
14
/**
15
 * @author Sean Johnson <[email protected]>
16
 */
17
final class ShowResponse implements ApiResponse
18
{
19
    /**
20
     * @var string
21
     */
22
    private $address;
23
24
    /**
25
     * @var string
26
     */
27
    private $code;
28
29
    /**
30
     * @var string
31
     */
32
    private $error;
33
34
    /**
35
     * @var \DateTime
36
     */
37
    private $createdAt;
38
39
    /**
40
     * @param string $address
41
     */
42
    private function __construct($address)
43
    {
44
        $this->address = $address;
45
        $this->createdAt = new \DateTime();
46
    }
47
48
    /**
49
     * @param array $data
50
     *
51
     * @return ShowResponse
52
     */
53
    public static function create(array $data)
54
    {
55
        $bounce = new self($data['address']);
56
57
        if (isset($data['code'])) {
58
            $bounce->setCode($data['code']);
59
        }
60
        if (isset($data['error'])) {
61
            $bounce->setError($data['error']);
62
        }
63
        if (isset($data['created_at'])) {
64
            $bounce->setCreatedAt(new \DateTime($data['created_at']));
65
        }
66
67
        return $bounce;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getAddress()
74
    {
75
        return $this->address;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function getCode()
82
    {
83
        return $this->code;
84
    }
85
86
    /**
87
     * @param string $code
88
     */
89
    private function setCode($code)
90
    {
91
        $this->code = $code;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function getError()
98
    {
99
        return $this->error;
100
    }
101
102
    /**
103
     * @param string $error
104
     */
105
    private function setError($error)
106
    {
107
        $this->error = $error;
108
    }
109
110
    /**
111
     * @return \DateTime
112
     */
113
    public function getCreatedAt()
114
    {
115
        return $this->createdAt;
116
    }
117
118
    /**
119
     * @param \DateTime $createdAt
120
     */
121
    private function setCreatedAt(\DateTime $createdAt)
122
    {
123
        $this->createdAt = $createdAt;
124
    }
125
}
126