public function isInRange(string $range): bool
    {
        $targetRange = strtolower($range);
        $myIP = bin2hex(inet_pton($this->address));

        if (strpos($targetRange, '-') !== false) {
            $parts = explode('-', $targetRange);
            if (count($parts) > 2) {
                throw new \InvalidArgumentException(sprintf('Invalid range "%s" given.', $range));
            }

            $firstIP = bin2hex(inet_pton(trim($parts[0])));
            $lastIP = bin2hex(inet_pton(trim($parts[1])));

            return $myIP >= $firstIP && $myIP <= $lastIP;
        } elseif (strpos($targetRange, '/') !== false) {
            $parts = explode('/', $targetRange);
            if (count($parts) > 2) {
                throw new \InvalidArgumentException(sprintf('Invalid range "%s" given.', $range));
            }

            if (strpos($parts[0], '.') !== false) {
                $x = explode('.', trim($parts[0]));
                while (count($x) < 4) {
                    $x[] = '0';
                }

                $firstIP = bin2hex(inet_pton(implode('.', $x)));
                $variableBits = 32 - $parts[1];
                $pos = 7;
            } else {
                $firstIP = bin2hex(inet_pton(trim($parts[0])));
                $variableBits = 128 - $parts[1];
                $pos = 31;
            }

            $lastIP = $firstIP;
            while ($variableBits > 0) {
                $oldValue = hexdec(substr($lastIP, $pos, 1));
                $newValue = $oldValue | (pow(2, min(4, $variableBits)) - 1);
                $lastIP = substr_replace($lastIP, dechex($newValue), $pos, 1);
                $variableBits -= 4;
                $pos -= 1;
            }

            return $myIP >= $firstIP && $myIP <= $lastIP;
        } else {
            try {
                $targetIP = new self($targetRange);

                return $this->isEqualTo($targetIP);
            } catch (\InvalidArgumentException $e) {
                throw new \InvalidArgumentException(sprintf('Invalid range "%s" given.', $range));
            }
        }
    }