Completed
Push — master ( b6d035...da6ee3 )
by Sean
03:40
created

ShowResponse::setCreatedAt()   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 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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\Resource\Api\Suppressions\Complaint;
11
12
use Mailgun\Resource\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
            $this->setCreatedAt(new \DateTime($data['created_at']));
0 ignored issues
show
Bug introduced by
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
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