Redaxscript\Validator\Dns::validate PHP Method

validate() public method

validate the dns
Since: 2.2.0
public validate ( string $host = null, string $type = 'A' ) : integer
$host string host of the domain
$type string optional domain type
return integer
    public function validate($host = null, $type = 'A')
    {
        $output = ValidatorInterface::FAILED;
        /* validate dns */
        if ($host) {
            if (function_exists('checkdnsrr') && checkdnsrr($host, $type) === false) {
                $output = ValidatorInterface::FAILED;
            } else {
                $output = ValidatorInterface::PASSED;
            }
        }
        return $output;
    }

Usage Example

Example #1
0
 /**
  * testDns
  *
  * @since 2.2.0
  *
  * @param string $host
  * @param string $type
  * @param integer $expect
  *
  * @dataProvider providerDns
  */
 public function testDns($host = null, $type = null, $expect = null)
 {
     /* setup */
     $validator = new Validator\Dns();
     /* actual */
     $actual = $validator->validate($host, $type);
     /* compare */
     $this->assertEquals($expect, $actual);
 }