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

ShowResponse   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 61
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A create() 0 10 2
A getAddress() 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\Complaint;
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 \DateTime
26
     */
27
    private $createdAt;
28
29
    /**
30
     * @param string $address
31
     */
32
    private function __construct($address)
33
    {
34
        $this->address = $address;
35
        $this->createdAt = new \DateTime();
36
    }
37
38
    /**
39
     * @param array $data
40
     *
41
     * @return ShowResponse
42
     */
43
    public static function create(array $data)
44
    {
45
        $bounce = new self($data['address']);
46
47
        if (isset($data['created_at'])) {
48
            $bounce->setCreatedAt(new \DateTime($data['created_at']));
49
        }
50
51
        return $bounce;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getAddress()
58
    {
59
        return $this->address;
60
    }
61
62
    /**
63
     * @return \DateTime
64
     */
65
    public function getCreatedAt()
66
    {
67
        return $this->createdAt;
68
    }
69
70
    /**
71
     * @param \DateTime $createdAt
72
     */
73
    private function setCreatedAt(\DateTime $createdAt)
74
    {
75
        $this->createdAt = $createdAt;
76
    }
77
}
78