Assert that the status code is valid (100..999)

@param string $code
@throws \InvalidArgumentException
504423
protected function assertStatusCode($code)
    {
        if (!is_int($code) && !(is_string($code) && ctype_digit($code))) {
            throw new \InvalidArgumentException("Response code must be integer");
        }
        
        if ($code < 100 || $code > 999) {
            throw new \InvalidArgumentException("Response code must be in range 100...999");
        }
    }
44219
public static function isValidCode( $code ) {
		return
			strcspn( $code, ":/\\\000" ) === strlen( $code )
			&& !preg_match( Title::getTitleInvalidRegex(), $code );
	}
328308
public function setHttpStatusCode($code)
    {
        $code = intval($code);
        if (!is_int($code)
            || $code < 100
            || $code > 599
        ) {
            trigger_error('Invalid HTTP status code, not taken into account.', E_USER_WARNING);
            return false;
        }
        $this->httpStatusCode = $code;
        return true;
    }
1353612
protected function validateStatusCode(int $code): int
    {
        if (!is_numeric($code) || is_float($code) || 100 > $code || 599 < $code) {
            throw new InvalidStatusException(
                'Invalid status code. Must be an integer between 100 and 599, inclusive.'
            );
        }

        return $code;
    }
1140213
public static function validate($code = '', $key = -1)
    {
        if (strlen($key) < 1) {
            return false;
        }

        if (!is_numeric($key)) {
            return false;
        }

        if (!is_string($code)) {
            return false;
        }

        if (strlen($code) < 2) {
            return false;
        }

        $numerals = str_split($code);
        $rank = array_reverse(array_keys($numerals));
        $orderedNumerals = array();
        foreach ($rank as $i => $rankValue) {
            $orderedNumerals[$rankValue + 1] = $numerals[$i];
        }
        $results = array();
        foreach ($orderedNumerals as $cle => $value) {
            $results[$value] = ($cle % 2 == 0) ? ((int) $value * 1) : ((int) $value * 2);
        }
        $sum = 0;
        foreach ($results as $cle => $value) {
            $sum += array_sum(str_split($value));
        }
        $validKey = str_split($sum);
        $validKey = 10 - array_pop($validKey);

        return $key === $validKey;
    }
93061
public function setResponseCode(int $code)
    {
        if ($code < 100 || $code > 599)
        {
            $err = new \InvalidArgumentException("Attempting to set status code to $code");
            self::$logger->critical("Invalid status {0}: {1}", [$code, $err]);
            $this->response_code = 500;
        }
        else
        {
            $this->response_code = $code;
        }
        return $this;
    }
1279713
public function check($code)
    {
        $promocode = Promocode::byCode($code)->first();

        if ($promocode === null) {
            throw new InvalidPromocodeException;
        }

        if ($promocode->isExpired() || ($promocode->isDisposable() && $promocode->users()->exists())) {
            return false;
        }

        return $promocode;
    }
1371718
public function setCode($code)
    {
        if (!is_scalar($code)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Wrong parameters for %s([int|string $code]); %s given.',
                    __METHOD__,
                    is_object($code) ? get_class($code) : gettype($code)
                ),
                E_ERROR
            );
        }

        $this->code = $code;

        return $this;
    }
102655
public static function valueOf($code = self::NONE)
    {
        if (self::isValidCode($code)) {
            $details = self::getDetails($code);
            $code = $details['code'];
            $isoStatus = $details['isoStatus'];
            $decimalDigits = $details['decimalDigits'];
            $name = $details['name'];

            return new Currency($code, $isoStatus, $decimalDigits, $name);
        } else {
            throw new \InvalidArgumentException('Unknown currency code \'' . $code . '\'.');
        }
    }
1143595
public function validateCode($code)
    {
        $coupon = $this->_controller->getRepository()->find(array('code' => $code));

        if ($coupon && !$coupon->expired()) {
            $discount = $coupon->discount * 100;
            $this->setMessage(AnTranslator::sprintf('COM-SUBSCRIPTIONS-VALID-COUPON', $discount));
            return true;
        } else {
            $this->setMessage(AnTranslator::_('COM-SUBSCRIPTIONS-INVALID-COUPON'));
            return false;
        }
    }
616564
public function setHttpResponseCode($code)
        {
            if (!is_int($code) || (100 > $code) || (599 < $code)) {
                throw new Exception('Invalid HTTP response code');
            }

            if ((300 <= $code) && (307 >= $code)) {
                $this->_isRedirect = true;
            } else {
                $this->_isRedirect = false;
            }

            $this->_httpResponseCode = $code;

            return $this;
        }
118316
protected function validate($code)
    {
        list($class, $index) = property_exists($this, 'lightness') ? ['hsl', 2] : ['hsv', 3];
        $color = str_replace([$class, '(', ')', ' ', '%'], '', DefinedColor::find($code, $index));
        if (preg_match('/^(\d{1,3}),(\d{1,3}),(\d{1,3})$/', $color, $matches)) {
            if ($matches[1] > 360 || $matches[2] > 100 || $matches[3] > 100) {
                return false;
            }
            return $color;
        }
        return false;
    }
280015
protected function validate($code)
    {
        $color = str_replace('#', '', DefinedColor::find($code));
        if (strlen($color) === 3) {
            $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
        }
        return preg_match('/^[a-f0-9]{6}$/i', $color) ? $color : false;
    }
479111
public function setStatus(int $statusCode):ResponseBuilder
    {
        if ($statusCode < 400 || $statusCode >= 600) {
            throw new InvalidArgumentException("{$statusCode} is not a valid error HTTP status code.");
        }
        return parent::setStatus($statusCode);
    }
545985
protected function setPostcode(string $postcode): void
    {
        if (! preg_match(self::POSTCODE_FORMAT, $postcode)) {
            throw new InvalidArgumentException('Postcode must match the expected format: ' . self::POSTCODE_FORMAT);
        }

        $this->postcode = $postcode;
    }
630528
protected function _setStatus($code, $reasonPhrase = '')
    {
        if (!isset($this->_statusCodes[$code])) {
            throw new InvalidArgumentException(sprintf(
                'Invalid status code: %s. Use a valid HTTP status code in range 1xx - 5xx.',
                $code
            ));
        }

        $this->_status = $code;
        if (empty($reasonPhrase)) {
            $reasonPhrase = $this->_statusCodes[$code];
        }
        $this->_reasonPhrase = $reasonPhrase;
        $this->_setContentType();
    }
1229734
public function setOpcode($opcode)
    {
        if (!self::validateOpcode($opcode)) {
            throw new InvalidArgumentException("Invalid opcode");
        }

        $this->firstFrameByte = $this->firstFrameByte & 240;
        $this->firstFrameByte |= $opcode;
    }