Domain::__get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
// ---------------------------------------------------------------------
4
//
5
//  Copyright (C) 2018-2024 Artem Rodygin
6
//
7
//  You should have received a copy of the MIT License along with
8
//  this file. If not, see <https://opensource.org/licenses/MIT>.
9
//
10
// ---------------------------------------------------------------------
11
12
namespace Linode\Domains;
13
14
use Linode\Domains\Repository\DomainRecordRepository;
15
use Linode\Entity;
16
17
/**
18
 * A domain zonefile in our DNS system. You must own the domain name and tell your
19
 * registrar to use Linode's nameservers in order for a domain in our system to be
20
 * treated as authoritative.
21
 *
22
 * @property int                             $id          This Domain's unique ID
23
 * @property string                          $domain      The domain this Domain represents. Domain labels cannot be longer than 63
24
 *                                                        characters and must conform to RFC1035. Domains must be unique on Linode's
25
 *                                                        platform, including across different Linode accounts; there cannot be two Domains
26
 *                                                        representing the same domain.
27
 * @property string                          $type        Whether this Domain represents the authoritative source of information for the
28
 *                                                        domain it describes ("master"), or whether it is a read-only copy of a master
29
 *                                                        ("slave").
30
 * @property string                          $status      Used to control whether this Domain is currently being rendered.
31
 * @property string                          $soa_email   Start of Authority email address. This is required for `type` master Domains.
32
 * @property string                          $group       The group this Domain belongs to. This is for display purposes only.
33
 * @property string                          $description A description for this Domain. This is for display purposes only.
34
 * @property int                             $ttl_sec     "Time to Live" - the amount of time in seconds that this Domain's records may be
35
 *                                                        cached by resolvers or other domain servers.
36
 *                                                        * Valid values are 0, 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600,
37
 *                                                        604800, 1209600, and 2419200.
38
 *                                                        * Any other value is rounded up to the nearest valid value.
39
 *                                                        * A value of 0 is equivalent to the default value of 86400.
40
 * @property int                             $refresh_sec The amount of time in seconds before this Domain should be refreshed.
41
 *                                                        * Valid values are
42
 *                                                        0, 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600,
43
 *                                                        and 2419200.
44
 *                                                        * Any other value is rounded up to the nearest valid value.
45
 *                                                        * A value of 0 is equivalent to the default value of 14400.
46
 * @property int                             $retry_sec   The interval, in seconds, at which a failed refresh should be retried.
47
 *                                                        * Valid values are
48
 *                                                        0, 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600,
49
 *                                                        and 2419200.
50
 *                                                        * Any other value is rounded up to the nearest valid value.
51
 *                                                        * A value of 0 is equivalent to the default value of 14400.
52
 * @property int                             $expire_sec  The amount of time in seconds that may pass before this Domain is no longer
53
 *                                                        authoritative.
54
 *                                                        * Valid values are
55
 *                                                        0, 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600,
56
 *                                                        and 2419200.
57
 *                                                        * Any other value is rounded up to the nearest valid value.
58
 *                                                        * A value of 0 is equivalent to the default value of 1209600.
59
 * @property string[]                        $master_ips  The IP addresses representing the master DNS for this Domain. At least one value
60
 *                                                        is required for `type` slave Domains. The total combined length of all data within
61
 *                                                        this array cannot exceed 1000 characters.
62
 * @property string[]                        $axfr_ips    The list of IPs that may perform a zone transfer for this Domain. The total
63
 *                                                        combined length of all data within this array cannot exceed 1000 characters.
64
 *                                                        **Note**: This is potentially dangerous, and should be set to an empty list unless
65
 *                                                        you intend to use it.
66
 * @property string[]                        $tags        An array of tags applied to this object. Tags are for organizational purposes
67
 *                                                        only.
68
 * @property DomainRecordRepositoryInterface $records     Domain records.
69
 */
70
class Domain extends Entity
71
{
72
    // Available fields.
73
    public const FIELD_ID          = 'id';
74
    public const FIELD_DOMAIN      = 'domain';
75
    public const FIELD_TYPE        = 'type';
76
    public const FIELD_STATUS      = 'status';
77
    public const FIELD_SOA_EMAIL   = 'soa_email';
78
    public const FIELD_GROUP       = 'group';
79
    public const FIELD_DESCRIPTION = 'description';
80
    public const FIELD_TTL_SEC     = 'ttl_sec';
81
    public const FIELD_REFRESH_SEC = 'refresh_sec';
82
    public const FIELD_RETRY_SEC   = 'retry_sec';
83
    public const FIELD_EXPIRE_SEC  = 'expire_sec';
84
    public const FIELD_MASTER_IPS  = 'master_ips';
85
    public const FIELD_AXFR_IPS    = 'axfr_ips';
86
    public const FIELD_TAGS        = 'tags';
87
88
    // `FIELD_TYPE` values.
89
    public const TYPE_MASTER = 'master';
90
    public const TYPE_SLAVE  = 'slave';
91
92
    // `FIELD_STATUS` values.
93
    public const STATUS_DISABLED = 'disabled';
94
    public const STATUS_ACTIVE   = 'active';
95
96
    // Time values.
97
    public const TIME_DEFAULT  = 0;
98
    public const TIME_5_MINS   = 300;
99
    public const TIME_1_HOUR   = 3600;
100
    public const TIME_2_HOURS  = 7200;
101
    public const TIME_4_HOURS  = 14400;
102
    public const TIME_8_HOURS  = 28800;
103
    public const TIME_16_HOURS = 57600;
104
    public const TIME_1_DAY    = 86400;
105
    public const TIME_2_DAYS   = 172800;
106
    public const TIME_4_DAYS   = 345600;
107
    public const TIME_1_WEEK   = 604800;
108
    public const TIME_2_WEEKS  = 1209600;
109
    public const TIME_4_WEEKS  = 2419200;
110
111
    /**
112
     * @codeCoverageIgnore This method was autogenerated.
113
     */
114
    public function __get(string $name): mixed
115
    {
116
        return match ($name) {
117
            'records' => new DomainRecordRepository($this->client, $this->id),
118
            default   => parent::__get($name),
119
        };
120
    }
121
}
122