Completed
Push — master ( 83800d...869eff )
by David
04:46
created

Unsubscribe::getTags()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * Copyright (C) 2013 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 \DateTime
24
     */
25
    private $createdAt;
26
27
    /**
28
     * @var array
29
     */
30
    private $tags = [];
31
32
    /**
33
     * @param string $address
34
     */
35 2
    private function __construct($address)
36
    {
37 2
        $this->address = $address;
38 2
        $this->createdAt = new \DateTime();
39 2
    }
40
41
    /**
42
     * @param array $data
43
     *
44
     * @return Unsubscribe
45
     */
46 2
    public static function create(array $data)
47
    {
48 2
        $unsubscribe = new self($data['address']);
49
50 2
        if (isset($data['tags'])) {
51 1
            $unsubscribe->setTags($data['tags']);
52 1
        }
53 2
        if (isset($data['created_at'])) {
54
            $unsubscribe->setCreatedAt(new \DateTime($data['created_at']));
55
        }
56
57 2
        return $unsubscribe;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getAddress()
64
    {
65
        return $this->address;
66
    }
67
68
    /**
69
     * @return \DateTime
70
     */
71
    public function getCreatedAt()
72
    {
73
        return $this->createdAt;
74
    }
75
76
    /**
77
     * @param \DateTime $createdAt
78
     */
79
    private function setCreatedAt(\DateTime $createdAt)
80
    {
81
        $this->createdAt = $createdAt;
82
    }
83
84
    /**
85
     * @param array $tags
86
     */
87 1
    private function setTags($tags)
88
    {
89 1
        $this->tags = $tags;
90 1
    }
91
92
    /**
93
     * @return array
94
     */
95 2
    public function getTags()
96
    {
97 2
        return $this->tags;
98
    }
99
}
100