Unverified Commit 1d13ba88 authored by Sam Williams's avatar Sam Williams Committed by GitHub
Browse files

Merge pull request #20 from Badcow/v1.0

V1.0
parents e34866d3 31b0669a
......@@ -3,4 +3,4 @@ phpunit.xml
composer.lock
coverage.clover
.php_cs
.idea/
\ No newline at end of file
language: php
php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm
install: composer install --no-interaction --prefer-source
script:
- phpunit --coverage-text --coverage-clover=coverage.clover
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
......
......@@ -9,10 +9,10 @@
}
],
"require": {
"php": ">=5.5"
"php": "~7.1"
},
"require-dev": {
"badcow/common": "dev-master"
"phpunit/phpunit": "~7.3"
},
"autoload": {
"psr-4": {
......
......@@ -11,19 +11,19 @@
namespace Badcow\DNS;
use Badcow\DNS\Rdata\AaaaRdata;
use Badcow\DNS\Rdata\ARdata;
use Badcow\DNS\Rdata\CnameRdata;
use Badcow\DNS\Rdata\DnameRdata;
use Badcow\DNS\Rdata\AAAA;
use Badcow\DNS\Rdata\A;
use Badcow\DNS\Rdata\CNAME;
use Badcow\DNS\Rdata\DNAME;
use Badcow\DNS\Rdata\FormattableInterface;
use Badcow\DNS\Rdata\HinfoRdata;
use Badcow\DNS\Rdata\LocRdata;
use Badcow\DNS\Rdata\MxRdata;
use Badcow\DNS\Rdata\NsRdata;
use Badcow\DNS\Rdata\PtrRdata;
use Badcow\DNS\Rdata\SoaRdata;
use Badcow\DNS\Rdata\SrvRdata;
use Badcow\DNS\Rdata\TxtRdata;
use Badcow\DNS\Rdata\HINFO;
use Badcow\DNS\Rdata\LOC;
use Badcow\DNS\Rdata\MX;
use Badcow\DNS\Rdata\NS;
use Badcow\DNS\Rdata\PTR;
use Badcow\DNS\Rdata\SOA;
use Badcow\DNS\Rdata\SRV;
use Badcow\DNS\Rdata\TXT;
class AlignedBuilder implements ZoneBuilderInterface
{
......@@ -33,18 +33,18 @@ class AlignedBuilder implements ZoneBuilderInterface
* @var array
*/
private static $order = [
SoaRdata::TYPE,
NsRdata::TYPE,
ARdata::TYPE,
AaaaRdata::TYPE,
CnameRdata::TYPE,
DnameRdata::TYPE,
MxRdata::TYPE,
LocRdata::TYPE,
HinfoRdata::TYPE,
TxtRdata::TYPE,
PtrRdata::TYPE,
SrvRdata::TYPE,
SOA::TYPE,
NS::TYPE,
A::TYPE,
AAAA::TYPE,
CNAME::TYPE,
DNAME::TYPE,
MX::TYPE,
LOC::TYPE,
HINFO::TYPE,
TXT::TYPE,
PTR::TYPE,
SRV::TYPE,
];
/**
......@@ -56,7 +56,7 @@ class AlignedBuilder implements ZoneBuilderInterface
'$TTL ' . $zone->getDefaultTtl() . PHP_EOL;
$rrs = $zone->getResourceRecords();
$current = SoaRdata::TYPE;
$current = SOA::TYPE;
$namePadding = $ttlPadding = $typePadding = 0;
usort($rrs, 'self::compareResourceRecords');
......
......@@ -13,7 +13,7 @@ namespace Badcow\DNS\Rdata;
use Badcow\DNS\Validator;
class ARdata implements RdataInterface
class A implements RdataInterface
{
use RdataTrait;
......@@ -26,15 +26,9 @@ class ARdata implements RdataInterface
/**
* @param string $address
*
* @throws RdataException
*/
public function setAddress($address)
{
if (!Validator::validateIpv4Address($address)) {
throw new RdataException(sprintf('Address "%s" is not a valid IPv4 address', $address));
}
$this->address = $address;
}
......
......@@ -11,6 +11,9 @@
namespace Badcow\DNS\Rdata;
class RdataException extends \Exception
use Badcow\DNS\Validator;
class AAAA extends A
{
const TYPE = 'AAAA';
}
<?php
/*
* This file is part of Badcow DNS Library.
*
* (c) Samuel Williams <sam@badcow.co>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Badcow\DNS\Rdata;
use Badcow\DNS\Validator;
class AaaaRdata extends ARdata
{
const TYPE = 'AAAA';
/**
* @param string $address
*
* @throws RdataException
*/
public function setAddress($address)
{
if (!Validator::validateIpv6Address($address)) {
throw new RdataException(sprintf('Address "%s" is not a valid IPv6 address', $address));
}
$this->address = $address;
}
}
......@@ -13,7 +13,7 @@ namespace Badcow\DNS\Rdata;
use Badcow\DNS\Validator;
class CnameRdata implements RdataInterface
class CNAME implements RdataInterface
{
use RdataTrait;
......@@ -26,15 +26,9 @@ class CnameRdata implements RdataInterface
/**
* @param $target
*
* @throws RdataException
*/
public function setTarget($target)
{
if (!Validator::validateFqdn($target, false)) {
throw new RdataException(sprintf('The target "%s" is not a Fully Qualified Domain Name', $target));
}
$this->target = $target;
}
......
......@@ -21,7 +21,7 @@ namespace Badcow\DNS\Rdata;
*
* @link http://tools.ietf.org/html/rfc6672
*/
class DnameRdata extends CnameRdata
class DNAME extends CNAME
{
const TYPE = 'DNAME';
}
......@@ -15,13 +15,13 @@ use Badcow\DNS\Rdata\RdataInterface;
use Badcow\DNS\Rdata\RdataTrait;
/**
* Class DnskeyRdata
* Class DNSKEY
*
* {@link https://tools.ietf.org/html/rfc4034#section-2.1}
*
* @package Badcow\DNS\Rdata
*/
class DnskeyRdata implements RdataInterface
class DNSKEY implements RdataInterface
{
use RdataTrait;
......
......@@ -14,7 +14,7 @@ namespace Badcow\DNS\Rdata\DNSSEC;
use Badcow\DNS\Rdata\RdataInterface;
use Badcow\DNS\Rdata\RdataTrait;
class DsRdata implements RdataInterface
class DS implements RdataInterface
{
use RdataTrait;
......
......@@ -14,7 +14,7 @@ namespace Badcow\DNS\Rdata\DNSSEC;
use Badcow\DNS\Rdata\RdataInterface;
use Badcow\DNS\Rdata\RdataTrait;
class NsecRdata implements RdataInterface
class NSEC implements RdataInterface
{
use RdataTrait;
......
......@@ -14,7 +14,7 @@ namespace Badcow\DNS\Rdata\DNSSEC;
use Badcow\DNS\Rdata\RdataInterface;
use Badcow\DNS\Rdata\RdataTrait;
class RrsigRdata implements RdataInterface
class RRSIG implements RdataInterface
{
use RdataTrait;
......
......@@ -10,10 +10,10 @@
*/
namespace Badcow\DNS\Rdata;
use Badcow\DNS\Rdata\DNSSEC\DnskeyRdata;
use Badcow\DNS\Rdata\DNSSEC\DsRdata;
use Badcow\DNS\Rdata\DNSSEC\NsecRdata;
use Badcow\DNS\Rdata\DNSSEC\RrsigRdata;
use Badcow\DNS\Rdata\DNSSEC\DNSKEY;
use Badcow\DNS\Rdata\DNSSEC\DS;
use Badcow\DNS\Rdata\DNSSEC\NSEC;
use Badcow\DNS\Rdata\DNSSEC\RRSIG;
class Factory
{
......@@ -22,11 +22,11 @@ class Factory
*
* @param string $address
*
* @return AaaaRdata
* @return AAAA
*/
public static function Aaaa($address)
{
$rdata = new AaaaRdata();
$rdata = new AAAA();
$rdata->setAddress($address);
return $rdata;
......@@ -37,11 +37,11 @@ class Factory
*
* @param string $address
*
* @return ARdata
* @return A
*/
public static function A($address)
{
$rdata = new ARdata();
$rdata = new A();
$rdata->setAddress($address);
return $rdata;
......@@ -52,11 +52,11 @@ class Factory
*
* @param string $cname
*
* @return CnameRdata
* @return CNAME
*/
public static function Cname($cname)
{
$rdata = new CnameRdata();
$rdata = new CNAME();
$rdata->setTarget($cname);
return $rdata;
......@@ -66,11 +66,11 @@ class Factory
* @param string $cpu
* @param string $os
*
* @return HinfoRdata
* @return HINFO
*/
public static function Hinfo($cpu, $os)
{
$rdata = new HinfoRdata();
$rdata = new HINFO();
$rdata->setCpu($cpu);
$rdata->setOs($os);
......@@ -81,11 +81,11 @@ class Factory
* @param int $preference
* @param string $exchange
*
* @return MxRdata
* @return MX
*/
public static function Mx($preference, $exchange)
{
$rdata = new MxRdata();
$rdata = new MX();
$rdata->setPreference($preference);
$rdata->setExchange($exchange);
......@@ -101,11 +101,11 @@ class Factory
* @param int $expire
* @param int $minimum
*
* @return SoaRdata
* @return SOA
*/
public static function Soa($mname, $rname, $serial, $refresh, $retry, $expire, $minimum)
{
$rdata = new SoaRdata();
$rdata = new SOA();
$rdata->setMname($mname);
$rdata->setRname($rname);
$rdata->setSerial($serial);
......@@ -120,11 +120,11 @@ class Factory
/**
* @param string $nsdname
*
* @return NsRdata
* @return NS
*/
public static function Ns($nsdname)
{
$rdata = new NsRdata();
$rdata = new NS();
$rdata->setTarget($nsdname);
return $rdata;
......@@ -133,11 +133,11 @@ class Factory
/**
* @param string $text
*
* @return TxtRdata
* @return TXT
*/
public static function txt($text)
{
$rdata = new TxtRdata();
$rdata = new TXT();
$rdata->setText($text);
return $rdata;
......@@ -146,11 +146,11 @@ class Factory
/**
* @param string $target
*
* @return DnameRdata
* @return DNAME
*/
public static function Dname($target)
{
$rdata = new DnameRdata();
$rdata = new DNAME();
$rdata->setTarget($target);
return $rdata;
......@@ -164,11 +164,11 @@ class Factory
* @param float $hp
* @param float $vp
*
* @return LocRdata
* @return LOC
*/
public static function Loc($lat, $lon, $alt = 0.0, $size = 1.0, $hp = 10000.0, $vp = 10.0)
{
$rdata = new LocRdata();
$rdata = new LOC();
$rdata->setLatitude($lat);
$rdata->setLongitude($lon);
$rdata->setAltitude($alt);
......@@ -182,11 +182,11 @@ class Factory
/**
* @param string $target
*
* @return PtrRdata
* @return PTR
*/
public static function Ptr($target)
{
$rdata = new PtrRdata();
$rdata = new PTR();
$rdata->setTarget($target);
return $rdata;
......@@ -197,11 +197,11 @@ class Factory
* @param int $algorithm
* @param string $publicKey
*
* @return DnskeyRdata
* @return DNSKEY
*/
public static function Dnskey($flags, $algorithm, $publicKey)
{
$rdata = new DnskeyRdata();
$rdata = new DNSKEY();
$rdata->setFlags($flags);
$rdata->setAlgorithm($algorithm);
$rdata->setPublicKey($publicKey);
......@@ -214,11 +214,11 @@ class Factory
* @param int $algorithm
* @param string $digest
*
* @return DsRdata
* @return DS
*/
public static function Ds($keyTag, $algorithm, $digest)
{
$rdata = new DsRdata();
$rdata = new DS();
$rdata->setKeyTag($keyTag);
$rdata->setAlgorithm($algorithm);
$rdata->setDigest($digest);
......@@ -230,11 +230,11 @@ class Factory
* @param $nextDomainName
* @param array $typeBitMaps
*
* @return NsecRdata
* @return NSEC
*/
public static function Nsec($nextDomainName, array $typeBitMaps)
{
$rdata = new NsecRdata();
$rdata = new NSEC();
$rdata->setNextDomainName($nextDomainName);
array_map([$rdata, 'addTypeBitMap'], $typeBitMaps);
......@@ -252,13 +252,13 @@ class Factory
* @param $signersName
* @param $signature
*
* @return RrsigRdata
* @return RRSIG
*/
public function Rrsig($typeCovered, $algorithm, $labels, $originalTtl,
$signatureExpiration, $signatureInception, $keyTag,
$signersName, $signature)
{
$rdata = new RrsigRdata();
$rdata = new RRSIG();
$rdata->setTypeCovered($typeCovered);
$rdata->setAlgorithm($algorithm);
$rdata->setLabels($labels);
......
......@@ -11,7 +11,7 @@
namespace Badcow\DNS\Rdata;
class HinfoRdata implements RdataInterface
class HINFO implements RdataInterface
{
use RdataTrait;
......
......@@ -21,7 +21,7 @@ use Badcow\DNS\ResourceRecord;
*
* @link http://tools.ietf.org/html/rfc1876
*/
class LocRdata implements RdataInterface, FormattableInterface
class LOC implements RdataInterface, FormattableInterface
{
use RdataTrait, FormattableTrait;
......
......@@ -13,7 +13,7 @@ namespace Badcow\DNS\Rdata;
use Badcow\DNS\Validator;
class MxRdata implements RdataInterface
class MX implements RdataInterface
{
use RdataTrait;
......@@ -31,15 +31,9 @@ class MxRdata implements RdataInterface
/**
* @param string $exchange
*
* @throws RdataException
*/
public function setExchange($exchange)
{
if (!Validator::validateFqdn($exchange)) {
throw new RdataException(sprintf('The exchange "%s" is not a Fully Qualified Domain Name', $exchange));
}
$this->exchange = $exchange;
}
......
......@@ -11,7 +11,7 @@
namespace Badcow\DNS\Rdata;
class NsRdata extends CnameRdata
class NS extends CNAME
{
const TYPE = 'NS';
}
<?php
/*
* This file is part of Badcow DNS Library.
*
* (c) Samuel Williams <sam@badcow.co>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Badcow\DNS\Rdata;
/**
* @deprecated
*/
class NiceSoaRdata extends SoaRdata
{
public function output()
{
return $this->outputFormatted();
}
}
......@@ -11,7 +11,7 @@
namespace Badcow\DNS\Rdata;
class PtrRdata extends CnameRdata
class PTR extends CNAME
{
const TYPE = 'PTR';
}
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