Example #1
0
 /**
  * Construct and validate domain
  *
  * @param string  $strDomainName
  * @param boolean $booIntranet Is the domain name to be correct not only the Internet but also on the local network
  * @throws InvalidDomainException
  */
 public function __construct($strDomainName, $booIntranet = false)
 {
     $booIntranet = (bool) $booIntranet;
     if (!DomainUtils::isValid($strDomainName, $booIntranet)) {
         throw new InvalidDomainException('Invalid domain name "' . var_export($strDomainName, true) . '"');
     }
     $this->strDomainName = strtolower($strDomainName);
     $this->booIntranet = $booIntranet;
 }
Example #2
0
 /**
  * @covers Etechnika\ExtLib\Domain\DomainUtils::isValid
  * @dataProvider providerIsValid
  */
 public function testIsValid($strIn, $booIntranet, $booTrue)
 {
     try {
         if ($booTrue) {
             $this->assertTrue(DomainUtils::isValid($strIn, $booIntranet), 'Domain name: ' . $strIn . ' Intranet: ' . var_export($booIntranet, true));
         } else {
             $this->assertFalse(DomainUtils::isValid($strIn, $booIntranet), 'Domain name: ' . $strIn . ' Intranet: ' . var_export($booIntranet, true));
         }
     } catch (Exception $e) {
         $this->fail('Unexpected exception');
     }
     // endtry
 }