|
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\Domain; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Represents domain information in its simplest form. |
|
14
|
|
|
* |
|
15
|
|
|
* @author Sean Johnson <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
final class Domain |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var \DateTime |
|
21
|
|
|
*/ |
|
22
|
|
|
private $createdAt; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
private $smtpLogin; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
private $name; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
private $smtpPassword; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var bool |
|
41
|
|
|
*/ |
|
42
|
|
|
private $wildcard; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
private $spamAction; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var string |
|
51
|
|
|
*/ |
|
52
|
|
|
private $state; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param array $data |
|
56
|
|
|
* |
|
57
|
|
|
* @return self |
|
58
|
|
|
*/ |
|
59
|
|
|
public static function create(array $data) |
|
60
|
|
|
{ |
|
61
|
|
|
return new self( |
|
62
|
|
|
isset($data['name']) ? $data['name'] : null, |
|
63
|
|
|
isset($data['smtp_login']) ? $data['smtp_login'] : null, |
|
64
|
|
|
isset($data['smtp_password']) ? $data['smtp_password'] : null, |
|
65
|
|
|
isset($data['wildcard']) ? $data['wildcard'] : null, |
|
66
|
|
|
isset($data['spam_action']) ? $data['spam_action'] : null, |
|
67
|
|
|
isset($data['state']) ? $data['state'] : null, |
|
68
|
|
|
isset($data['created_at']) ? new \DateTime($data['created_at']) : null |
|
|
|
|
|
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param string $name |
|
74
|
|
|
* @param string $smtpLogin |
|
75
|
|
|
* @param string $smtpPassword |
|
76
|
|
|
* @param bool $wildcard |
|
77
|
|
|
* @param string $spamAction |
|
78
|
|
|
* @param string $state |
|
79
|
|
|
* @param \DateTime $createdAt |
|
80
|
|
|
*/ |
|
81
|
|
|
private function __construct($name, $smtpLogin, $smtpPassword, $wildcard, $spamAction, $state, \DateTime $createdAt) |
|
82
|
|
|
{ |
|
83
|
|
|
$this->name = $name; |
|
84
|
|
|
$this->smtpLogin = $smtpLogin; |
|
85
|
|
|
$this->smtpPassword = $smtpPassword; |
|
86
|
|
|
$this->wildcard = $wildcard; |
|
87
|
|
|
$this->spamAction = $spamAction; |
|
88
|
|
|
$this->state = $state; |
|
89
|
|
|
$this->createdAt = $createdAt; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return string |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getName() |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->name; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @return string |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getSmtpUsername() |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->smtpLogin; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @return string |
|
110
|
|
|
*/ |
|
111
|
|
|
public function getSmtpPassword() |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->smtpPassword; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @return bool |
|
118
|
|
|
*/ |
|
119
|
|
|
public function isWildcard() |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->wildcard; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @return string |
|
126
|
|
|
*/ |
|
127
|
|
|
public function getSpamAction() |
|
128
|
|
|
{ |
|
129
|
|
|
return $this->spamAction; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @return string |
|
134
|
|
|
*/ |
|
135
|
|
|
public function getState() |
|
136
|
|
|
{ |
|
137
|
|
|
return $this->state; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @return \DateTime |
|
142
|
|
|
*/ |
|
143
|
|
|
public function getCreatedAt() |
|
144
|
|
|
{ |
|
145
|
|
|
return $this->createdAt; |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: