Completed
Push — master ( f58c59...8187a4 )
by Tobias
06:35
created

DnsRecord::getCached()   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
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
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\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
     * @var array
46
     */
47
    private $cached;
48
49
    /**
50
     * @param array $data
51
     *
52
     * @return self
53
     */
54 1
    public static function create(array $data)
55
    {
56 1
        $name = isset($data['name']) ? $data['name'] : null;
57 1
        $priority = isset($data['priority']) ? $data['priority'] : null;
58 1
        $recordType = isset($data['record_type']) ? $data['record_type'] : null;
59 1
        $value = isset($data['value']) ? $data['value'] : null;
60 1
        $valid = isset($data['valid']) ? $data['valid'] : null;
61 1
        $cached = isset($data['cached']) ? $data['cached'] : null;
62
63 1
        return new self($name, $recordType, $value, $priority, $valid, $cached);
64
    }
65
66
    /**
67
     * @param string|null $name     Name of the record, as used in CNAME, etc.
68
     * @param string      $type     DNS record type
69
     * @param string      $value    DNS record value
70
     * @param string|null $priority Record priority, used for MX
71
     * @param string      $valid    DNS record has been added to domain DNS?
72
     * @param array       $cached   DNS record current value
73
     */
74 1
    private function __construct($name, $type, $value, $priority, $valid, $cached)
75
    {
76 1
        $this->name = $name;
77 1
        $this->type = $type;
78 1
        $this->value = $value;
79 1
        $this->priority = $priority;
80 1
        $this->valid = $valid;
81 1
        $this->cached = $cached;
82 1
    }
83
84
    /**
85
     * @return string|null
86
     */
87
    public function getName()
88
    {
89
        return $this->name;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getType()
96
    {
97
        return $this->type;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getValue()
104
    {
105
        return $this->value;
106
    }
107
108
    /**
109
     * @return string|null
110
     */
111
    public function getPriority()
112
    {
113
        return $this->priority;
114
    }
115
116
    /**
117
     * @return bool
118
     */
119
    public function isValid()
120
    {
121
        return 'valid' === $this->valid;
122
    }
123
124
    /**
125
     * @return string
126
     */
127
    public function getValidity()
128
    {
129
        return $this->valid;
130
    }
131
132
    /**
133
     * @return array
134
     */
135
    public function getCached()
136
    {
137
        return $this->cached;
138
    }
139
}
140