|
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 a single DNS record for a domain. |
|
14
|
|
|
* |
|
15
|
|
|
* @author Sean Johnson <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
final class DnsRecord |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var string|null |
|
21
|
|
|
*/ |
|
22
|
|
|
private $name; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
private $type; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
private $value; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string|null |
|
36
|
|
|
*/ |
|
37
|
|
|
private $priority; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
private $valid; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param array $data |
|
46
|
|
|
* |
|
47
|
|
|
* @return self |
|
48
|
|
|
*/ |
|
49
|
|
|
public static function create(array $data) |
|
50
|
|
|
{ |
|
51
|
|
|
$name = isset($data['name']) ? $data['name'] : null; |
|
52
|
|
|
$priority = isset($data['priority']) ? $data['priority'] : null; |
|
53
|
|
|
$recordType = isset($data['record_type']) ? $data['record_type'] : null; |
|
54
|
|
|
$value = isset($data['value']) ? $data['value'] : null; |
|
55
|
|
|
$valid = isset($data['valid']) ? $data['valid'] : null; |
|
56
|
|
|
|
|
57
|
|
|
return new self($name, $recordType, $value, $priority, $valid); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param string|null $name Name of the record, as used in CNAME, etc. |
|
62
|
|
|
* @param string $type DNS record type |
|
63
|
|
|
* @param string $value DNS record value |
|
64
|
|
|
* @param string|null $priority Record priority, used for MX |
|
65
|
|
|
* @param string $valid DNS record has been added to domain DNS? |
|
66
|
|
|
*/ |
|
67
|
|
|
private function __construct($name, $type, $value, $priority, $valid) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->name = $name; |
|
70
|
|
|
$this->type = $type; |
|
71
|
|
|
$this->value = $value; |
|
72
|
|
|
$this->priority = $priority; |
|
73
|
|
|
$this->valid = $valid; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return string|null |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getName() |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->name; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return string |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getType() |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->type; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return string |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getValue() |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->value; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @return string|null |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getPriority() |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->priority; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @return bool |
|
110
|
|
|
*/ |
|
111
|
|
|
public function isValid() |
|
112
|
|
|
{ |
|
113
|
|
|
return 'valid' === $this->value; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @return string |
|
118
|
|
|
*/ |
|
119
|
|
|
public function getValidity() |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->valid; |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|