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

Unsubscribe::getCreatedAt()   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\Unsubscribe;
11
12
/**
13
 * @author Sean Johnson <[email protected]>
14
 */
15
class Unsubscribe
16
{
17
    /**
18
     * @var string
19
     */
20
    private $address;
21
22
    /**
23
     * @var string
24
     */
25
    private $tag;
26
27
    /**
28
     * @var \DateTime
29
     */
30
    private $createdAt;
31
32
    /**
33
     * @param string $address
34
     */
35
    private function __construct($address)
36
    {
37
        $this->address = $address;
38
        $this->createdAt = new \DateTime();
39
    }
40
41
    /**
42
     * @param array $data
43
     *
44
     * @return Unsubscribe
45
     */
46
    public static function create(array $data)
47
    {
48
        $unsubscribe = new self($data['address']);
49
50
        if (isset($data['tag'])) {
51
            $unsubscribe->setTag($data['tag']);
52
        }
53
        if (isset($data['created_at'])) {
54
            $unsubscribe->setCreatedAt(new \DateTime($data['created_at']));
55
        }
56
57
        return $unsubscribe;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getAddress()
64
    {
65
        return $this->address;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getTag()
72
    {
73
        return $this->tag;
74
    }
75
76
    /**
77
     * @param string $tag
78
     */
79
    private function setTag($tag)
80
    {
81
        $this->tag = $tag;
82
    }
83
84
    /**
85
     * @return \DateTime
86
     */
87
    public function getCreatedAt()
88
    {
89
        return $this->createdAt;
90
    }
91
92
    /**
93
     * @param \DateTime $createdAt
94
     */
95
    private function setCreatedAt(\DateTime $createdAt)
96
    {
97
        $this->createdAt = $createdAt;
98
    }
99
}
100