Calculates the content range that should be served.

@param  string      $range Request range
@return array|false
516711
protected function calculateRange(string $range)
	{
		// Remove the "range=" part of the header value

		$range = substr($range, 6);

		// Split the range starting and ending points

		$range = explode('-', $range, 2);

		// Check that the range contains two values

		if(count($range) !== 2)
		{
			return false;
		}

		// Determine start and ending points

		$end = $range[1] === '' ? $this->fileSize - 1 : $range[1];

		if($range[0] === '')
		{
			$start = $this->fileSize - $end;
			$end   = $this->fileSize - 1;
		}
		else
		{
			$start = $range[0];
		}

		$start = (int) $start;
		$end   = (int) $end;

		// Check that the range is satisfiable

		if($start > $end || $end + 1 > $this->fileSize)
		{
			return false;
		}

		// Return the range

		return ['start' => $start, 'end' => $end];
	}
311061
public function setRange($range)
    {
        $allowedValues = $this->getRangeAllowableValues();
        if (!in_array($range, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'range', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['range'] = $range;

        return $this;
    }
1110726
private static function parseRange($range, $partSize)
    {
        // Strip away the prefix and suffix.
        if (strpos($range, 'bytes') !== false) {
            $range = substr($range, 6, -2);
        }

        // Split that range into it's parts.
        list($firstByte, $lastByte) = explode('-', $range);

        // Calculate and return range index and range size
        return [
            intval($firstByte / $partSize) + 1,
            $lastByte - $firstByte + 1,
        ];
    }
1018948
public function asDatespan(DatespanRange $range = null)
    {
        $this->checkDefaultType(function() { return $this->default instanceof Datespan;}, Datespan::class);
        return $this->default;
    }
1000791
public function whereRange(string $field, $gt = null, $lt = null, $format = null, $gtConfig = "gte", $ltConfig = "lte")
    {
        if($gt && $lt) {
            $field = [];

            if($gt) {
                $field[$gtConfig] = $gt;
            }

            if($lt) {
                $field[$ltConfig] = $lt;
            }

            if($format) {
                $field["format"] = $format;
            }

            $param = [
                "range" => [
                    $field
                ]
            ];

            $this->elasticQuery[] = $param;
        }

        return $this;
    }
591212
public function abuts(DateTimeRange $range)
	{
		return !$this->overlaps($range) && $this->gap($range)->isEmpty();
	}
155268
public function getEmails($start = 0, $range = 10)
    {
        Argument::i()
            ->test(1, 'int')
            ->test(2, 'int');

        $total = $this->getEmailTotal();

        if ($total == 0) {
            return array();
        }

        if (!is_array($start)) {
            $range = $range > 0 ? $range : 1;
            $start = $start >= 0 ? $start : 0;
            $max = $total - $start;

            if ($max < 1) {
                $max = $total;
            }

            $min = $max - $range + 1;

            if ($min < 1) {
                $min = 1;
            }

            $set = $min . ':' . $max;

            if ($min == $max) {
                $set = $min;
            }
        }

        $emails = array();
        for ($i = $min; $i <= $max; $i++) {
            $emails[] = $this->getEmailFormat($this->call('RETR '.$i, true));
        }

        return $emails;
    }
492166
public function get($string = null, $range = '') {
        if($range) {
            $lang = isset($this->range[$range]) ? $this->range[$range] : [];
        }
        else {
            $lang = $this->lang;
        }

        foreach ($lang as $lg) {
            $count = 0;
            $string = $lg->translate($string, $count);
            if (-1 != $count) {
                break;
            }
        }

        return $string;
    }
1122064
public static function inRange(string $ip, string $range): bool
	{
		if(strpos($range, '/') === false)
		{
			$netmask = 32;
		}
		else
		{
			[$range, $netmask] = explode('/', $range, 2);

			if($netmask < 0 || $netmask > 32)
			{
				return false;
			}
		}

		if(($ip2Long = ip2long($ip)) === false || ($range2Long = ip2long($range)) === false)
		{
			return false;
		}

		$netmaskDecimal = ~ ((2 ** (32 - $netmask)) - 1);

		return ($ip2Long & $netmaskDecimal) === ($range2Long & $netmaskDecimal);
	}
956847
public function getNextLinks($range = 5)
    {
        $total = $this->getTotalPages();
        $start = $this->getPage() + 1;
        $end = $this->getPage() + $range;
        $last = $this->getLastPage();
        $links = array();
        for ($i = $start; $i < $end; $i++) {
            if ($i > $last) {
                break;
            }
            $links[] = $i;
        }

        return $links;
    }
186229
public static function reset($range = null)
    {
        static::_init();
        
        $range = $range ?: self::$range;
        if (true === $range) {
            self::$data->clear();
        } else {
            self::$data->set($range, []);
        }
    }
1111127
public function consume_range($chars)
	{
		if ($len = strspn($this->data, $chars, $this->position))
		{
			$data = substr($this->data, $this->position, $len);
			$this->consumed .= $data;
			$this->position += $len;
			return $data;
		}
		else
		{
			return false;
		}
	}
805183
public function getInRange($range = null) {
        if(is_null($range))
            $range = $this->range;
        $current_range = array( ($this->current_page-$range < 1 ? 1 : $this->current_page-$range),
            ($this->current_page+$range > $this->getMax() ? $this->getMax() : $this->current_page+$range));
        $rangeIDs = array();
        for($x = $current_range[0]; $x <= $current_range[1]; ++$x) {
            $rangeIDs[] = $x;
        }
        return $rangeIDs;
    }
882947
public function asDate(DateRange $range = null)
    {
        $this->default = (null === $this->default) ? (null) : (Date::castFrom($this->default, 'default'));
        return $this->default;
    }
1323804
protected function getHttpRange($fileSize)
    {
        $rangeHeader = $this->app->getRequest()->getHeaderLine('Range');

        if (empty($rangeHeader) || $rangeHeader === '-') {
            return [0, $fileSize - 1];
        }
        if (!preg_match('/^bytes=(\d*)-(\d*)$/', $rangeHeader, $matches)) {
            return false;
        }
        if ($matches[1] === '') {
            $start = $fileSize - $matches[2];
            $end = $fileSize - 1;
        } elseif ($matches[2] !== '') {
            $start = $matches[1];
            $end = $matches[2];
            if ($end >= $fileSize) {
                $end = $fileSize - 1;
            }
        } else {
            $start = $matches[1];
            $end = $fileSize - 1;
        }
        if ($start < 0 || $start > $end) {
            return false;
        }

        return [$start, $end];
    }
4397
public function get($string = null, $range = '') {
        if($range) {
            $value = isset($this->range[$range][$string]) ? $this->range[$range][$string] : $string;
        }
        else {
            $value = isset($this->lang[$string]) ? $this->lang[$string] : $string;
        }

        return $value;
    }
682903
public function setRange($range)
    {
        Argument::i()->test(1, 'int');
        
        if ($range < 0) {
            $range = 25;
        }
        
        $this->range = $range;
        
        return $this;
    }