Completed
Push — master ( 27d13d...ae9ee5 )
by Tobias
03:29
created

Bounce::getCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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
/**
13
 * @author Sean Johnson <[email protected]>
14
 */
15
class Bounce
16
{
17
    /**
18
     * @var string
19
     */
20
    private $address;
21
22
    /**
23
     * @var string
24
     */
25
    private $code;
26
27
    /**
28
     * @var string
29
     */
30
    private $error;
31
32
    /**
33
     * @var \DateTime
34
     */
35
    private $createdAt;
36
37
    /**
38
     * @param string $address
39
     */
40
    private function __construct($address)
41
    {
42
        $this->address = $address;
43
        $this->createdAt = new \DateTime();
44
    }
45
46
    /**
47
     * @param array $data
48
     *
49
     * @return Bounce
50
     */
51
    public static function create(array $data)
52
    {
53
        $bounce = new self($data['address']);
54
55
        if (isset($data['code'])) {
56
            $bounce->setCode($data['code']);
57
        }
58
        if (isset($data['error'])) {
59
            $bounce->setError($data['error']);
60
        }
61
        if (isset($data['created_at'])) {
62
            $bounce->setCreatedAt(new \DateTime($data['created_at']));
63
        }
64
65
        return $bounce;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getAddress()
72
    {
73
        return $this->address;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getCode()
80
    {
81
        return $this->code;
82
    }
83
84
    /**
85
     * @param string $code
86
     */
87
    private function setCode($code)
88
    {
89
        $this->code = $code;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getError()
96
    {
97
        return $this->error;
98
    }
99
100
    /**
101
     * @param string $error
102
     */
103
    private function setError($error)
104
    {
105
        $this->error = $error;
106
    }
107
108
    /**
109
     * @return \DateTime
110
     */
111
    public function getCreatedAt()
112
    {
113
        return $this->createdAt;
114
    }
115
116
    /**
117
     * @param \DateTime $createdAt
118
     */
119
    private function setCreatedAt(\DateTime $createdAt)
120
    {
121
        $this->createdAt = $createdAt;
122
    }
123
}
124