Commit 666d368f authored by Samuel Williams's avatar Samuel Williams
Browse files

CAA no longer extends CNAME.

parent 546b840a
......@@ -20,13 +20,21 @@ namespace Badcow\DNS\Rdata;
*
* @author Samuel Williams <sam@badcow.co>
*/
class CAA extends CNAME
class CAA implements RdataInterface
{
use RdataTrait;
const TYPE = 'CAA';
const MAX_FLAG = 255;
const ALLOWED_TAGS = ['issue', 'issuewild', 'iodef'];
const TAG_ISSUE = 'issue';
const TAG_ISSUEWILD = 'issuewild';
const TAG_IODEF = 'iodef';
const ALLOWED_TAGS = [self::TAG_ISSUE, self::TAG_ISSUEWILD, self::TAG_IODEF];
/**
* It is currently used to represent the critical flag
......@@ -46,6 +54,11 @@ class CAA extends CNAME
*/
private $tag;
/**
* @var string
*/
private $value;
/**
* @return int
*/
......@@ -69,7 +82,7 @@ class CAA extends CNAME
}
/**
* @return int
* @return string
*/
public function getTag(): ?string
{
......@@ -77,7 +90,7 @@ class CAA extends CNAME
}
/**
* @param int $tag
* @param string $tag
*
* @throws \InvalidArgumentException
*/
......@@ -90,6 +103,22 @@ class CAA extends CNAME
$this->tag = $tag;
}
/**
* @return string
*/
public function getValue(): string
{
return $this->value;
}
/**
* @param string $value
*/
public function setValue(string $value): void
{
$this->value = $value;
}
/**
* {@inheritdoc}
*/
......@@ -98,7 +127,7 @@ class CAA extends CNAME
return sprintf('%s %s "%s"',
$this->flag,
$this->tag,
$this->target
$this->value
);
}
}
......@@ -356,16 +356,16 @@ class Factory
/**
* @param integer $flag
* @param string $tag
* @param string $target
* @param string $value
*
* @return CAA
*/
public static function Caa($flag, $tag, $target)
public static function Caa($flag, $tag, $value): CAA
{
$rdata = new CAA();
$rdata->setFlag($flag);
$rdata->setTag($tag);
$rdata->setTarget($target);
$rdata->setValue($value);
return $rdata;
}
......
......@@ -44,4 +44,9 @@ class CaaRdataTest extends \PHPUnit\Framework\TestCase
$srv = new CAA();
$srv->setTag('not_exist');
}
public function testGetType()
{
$this->assertEquals('CAA', (new CAA)->getType());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment