예제 #1
0
 private function isRoutableRangeTest($range, $expectedBooleanResult)
 {
     $ipRangeSplit = explode('/', $range);
     $startIp = $ipRangeSplit[0];
     $cidrRange = (int) $ipRangeSplit[1];
     $ipCount = 1 << 32 - $cidrRange;
     $first = ip2long($startIp);
     $last = $first + $ipCount - 1;
     $ipsToTest = array_merge(array($first, $last), $this->getRandomLongIpSubsetInRange($first, $last));
     foreach ($ipsToTest as $longIp) {
         $host = new Host(long2ip($longIp));
         if ($expectedBooleanResult) {
             $this->assertTrue($host->isPubliclyRoutable());
         } else {
             $this->assertFalse($host->isPubliclyRoutable());
         }
     }
 }
예제 #2
0
파일: Host.php 프로젝트: webignition/url
 /**
  * 
  * @param \webignition\Url\Host\Host $comparator
  * @param array $excludeParts
  * @return boolean
  */
 public function isEquivalentTo(Host $comparator, $excludeParts = array())
 {
     $thisHost = new Host(\Etechnika\IdnaConvert\IdnaConvert::encodeString((string) $this));
     $comparatorHost = new Host(\Etechnika\IdnaConvert\IdnaConvert::encodeString((string) $comparator));
     if (!is_array($excludeParts) || count($excludeParts) == 0) {
         return $thisHost->equals($comparatorHost);
     }
     $thisParts = $this->excludeParts($thisHost->getParts(), $excludeParts);
     $comparatorParts = $this->excludeParts($comparatorHost->getParts(), $excludeParts);
     return $thisParts == $comparatorParts;
 }