Пример #1
0
 /**
  * @param IP|Network|Range $find
  * @return bool
  * @throws \Exception
  */
 public function contains($find)
 {
     if ($find instanceof IP) {
         $within = strcmp($find->inAddr(), $this->firstIP->inAddr()) >= 0 && strcmp($find->inAddr(), $this->lastIP->inAddr()) <= 0;
     } elseif ($find instanceof Range || $find instanceof Network) {
         /**
          * @var Network|Range $find
          */
         $within = strcmp($find->getFirstIP()->inAddr(), $this->firstIP->inAddr()) >= 0 && strcmp($find->getLastIP()->inAddr(), $this->lastIP->inAddr()) <= 0;
     } else {
         throw new \Exception('Invalid type');
     }
     return $within;
 }