Inspekt\Cage::testHostname PHP Method

testHostname() public method

Depending upon the value of $allow, Internet domain names, IP addresses, and/or local network names are considered valid. The default is HOST_ALLOW_ALL, which considers all of the above to be valid.
public testHostname ( mixed $key, integer $allow = Inspekt::ISPK_HOST_ALLOW_ALL ) : mixed
$key mixed
$allow integer bitfield for HOST_ALLOW_DNS, HOST_ALLOW_IP, HOST_ALLOW_LOCAL
return mixed
    public function testHostname($key, $allow = Inspekt::ISPK_HOST_ALLOW_ALL)
    {
        $value = $this->getValueOrNull($key);
        if (!is_null($value) && Inspekt::isHostname($value, $allow)) {
            return $value;
        }
        return false;
    }

Usage Example

Beispiel #1
0
 /**
  */
 public function testTestMethodsReturnFalseIfKeyDoesNotExist()
 {
     $this->assertFalse($this->cage->keyExists('/x/woot/0'));
     $this->assertFalse($this->cage->testAlpha('/x/woot/0'));
     $this->assertFalse($this->cage->testAlnum('/x/woot/0'));
     $this->assertFalse($this->cage->testBetween('/x/woot/0', 0, 5));
     $this->assertFalse($this->cage->testCcnum('/x/woot/0'));
     $this->assertFalse($this->cage->testDate('/x/woot/0'));
     $this->assertFalse($this->cage->testDigits('/x/woot/0'));
     $this->assertFalse($this->cage->testEmail('/x/woot/0'));
     $this->assertFalse($this->cage->testFloat('/x/woot/0'));
     $this->assertFalse($this->cage->testGreaterThan('/x/woot/0', 0));
     $this->assertFalse($this->cage->testHex('/x/woot/0'));
     $this->assertFalse($this->cage->testHostname('/x/woot/0'));
     $this->assertFalse($this->cage->testInt('/x/woot/0'));
     $this->assertFalse($this->cage->testIp('/x/woot/0'));
     $this->assertFalse($this->cage->testLessThan('/x/woot/0', 1));
     $this->assertFalse($this->cage->testOneOf('/x/woot/0', array(null, 0, 1, 2)));
     $this->assertFalse($this->cage->testPhone('/x/woot/0'));
     $this->assertFalse($this->cage->testRegex('/x/woot/0', "/null/"));
     $this->assertFalse($this->cage->testUri('/x/woot/0'));
     $this->assertFalse($this->cage->testZip('/x/woot/0'));
 }