-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecord.php
80 lines (70 loc) · 1.86 KB
/
Record.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php declare(strict_types=1);
/**
* Copyright (C) Apis Networks, Inc - All Rights Reserved.
*
* Unauthorized copying of this file, via any medium, is
* strictly prohibited without consent. Any dissemination of
* material herein is prohibited.
*
* For licensing inquiries email <[email protected]>
*
* Written by Matt Saladna <[email protected]>, September 2018
*/
namespace Opcenter\Dns\Providers\Aws;
class Record extends \Opcenter\Dns\Record
{
/**
* @var int $weight record weight
*/
protected $weight;
public function __construct(string $zone, array $args)
{
if (isset($args['name']) && ends_with($args['name'], $zone)) {
$args['name'] = rtrim((string)substr($args['name'], 0, \strlen($args['name']) - \strlen($zone)), '.');
}
parent::__construct($zone, $args);
if (null === $this->getMeta('id')) {
$this->setMeta('id', $this->hash());
}
}
protected function formatCaa()
{
$data = $this->getMeta('data');
if ($data[-1] === '"') {
// prevent doubly-escaping
return;
}
$this->setMeta('data', '"' . rtrim((string)$data, '.') . '"');
$this->parameter = $this->getMeta('flags') . ' ' .
$this->getMeta('tag') . ' ' . $this->getMeta('data');
}
protected function formatSpf() {
if ($this->parameter[-1] === '"') {
return;
}
$this->parameter = '"' . $this->parameter . '"';
}
public function parameterFromMeta(): string
{
return parent::parameterFromMeta();
}
/**
* @return array
*/
public function __debugInfo()
{
return [
'zone' => $this->zone,
'name' => $this->name,
'rr' => $this->rr,
'parameter' => $this->parameter,
'ttl' => $this->ttl,
'rweight' => $this->weight,
];
}
public function hash()
{
// sha256 gets truncated in API
return hash('md5', var_export($this, true));
}
}