Example #1
0
 /**
  * @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;
 }
Example #2
0
 public function testValidateIpv4Address()
 {
     $valid1 = '119.15.101.102';
     $valid2 = '255.0.0.255';
     $valid3 = '192.168.0.0';
     $valid4 = '0.0.0.0';
     $invalid1 = '192.168.1.';
     $invalid2 = '172.10.256.1';
     $invalid3 = '255.244';
     $invalid4 = '::1';
     $invalid5 = '2001:db8::ff00:42:8329';
     $this->assertTrue(Validator::validateIpv4Address($valid1));
     $this->assertTrue(Validator::validateIpv4Address($valid2));
     $this->assertTrue(Validator::validateIpv4Address($valid3));
     $this->assertTrue(Validator::validateIpv4Address($valid4));
     $this->assertFalse(Validator::validateIpv4Address($invalid1));
     $this->assertFalse(Validator::validateIpv4Address($invalid2));
     $this->assertFalse(Validator::validateIpv4Address($invalid3));
     $this->assertFalse(Validator::validateIpv4Address($invalid4));
     $this->assertFalse(Validator::validateIpv4Address($invalid5));
 }