public function __construct(IpAddress $ip, $mask)
 {
     Assert::isInteger($mask);
     if ($mask == 0 || self::MASK_MAX_SIZE < $mask) {
         throw new WrongArgumentException('wrong mask given');
     }
     $this->longMask = (int) (pow(2, 32 - $mask) * (pow(2, $mask) - 1));
     if (($ip->getLongIp() & $this->longMask) != $ip->getLongIp()) {
         throw new WrongArgumentException('wrong ip network given');
     }
     $this->ip = $ip;
     $this->mask = $mask;
 }
 private function setup(IpAddress $startIp, IpAddress $endIp)
 {
     if ($startIp->getLongIp() > $endIp->getLongIp()) {
         throw new WrongArgumentException('start ip must be lower than ip end');
     }
     $this->startIp = $startIp;
     $this->endIp = $endIp;
     return $this;
 }