Set response status from a status string.

@param string $statusLine Response status as a string.

@return $this

@throws \InvalidArgumentException For invalid status line.
4930
public function setStatus($statusLine)
    {
        $parts = explode(' ', $statusLine, 3);
        if (count($parts) < 2 || 0 !== strpos(strtolower($parts[0]), 'http/')) {
            throw new \InvalidArgumentException(
                sprintf('"%s" is not a valid HTTP status line', $statusLine)
            );
        }

        $reasonPhrase = count($parts) > 2 ? $parts[2] : '';
        $this->response = $this->response
            ->withStatus((int) $parts[1], $reasonPhrase)
            ->withProtocolVersion(substr($parts[0], 5));

        return $this;
    }
359868
public function setStatus($status)
    {
        if ($this->isValidStatus($status)) {
            $this->status = $status;
            $this->saveState();
        } else {
            throw new \InvalidArgumentException(
                sprintf("Status '%s' is not a valid status", $status)
            );
        }
    }
175969
public function setStatusCode($code)
	{
		if (!array_key_exists($code, self::$statusCodeMap)) {
			throw new InvalidArgumentException(sprintf('The HTTP stauts code %s is unknown.', $code));
		}

		$this->statusCode = $code;

		return $this;
	}
845969
public function setStatus($status)
    {
        $allowedStatuses = array(
            Job::STATUS_ERROR,
            Job::STATUS_SUCCESS,
            Job::STATUS_WARNING,
            Job::STATUS_TERMINATED
        );

        if (!in_array($status, $allowedStatuses)) {
            throw new \InvalidArgumentException(sprintf('Status "%s" is not allowed in JobException', $status));
        }

        $this->status = (string) $status;
        return $this;
    }
900783
public function set_status($status = self::STATUS_ACTIVE) {
        $this->statusactive = $status == static::STATUS_ACTIVE;
        $this->statussuspended = $status == static::STATUS_SUSPENDED;
        $this->statusnotcurrent = $status == static::STATUS_NOT_CURRENT;

        return $this;
    }
21971
public function withStatus(string $status): self
    {
        $this->status = ScheduledActionStatusEnum::ensureValid($status);
        return $this;
    }
781992
public function setStatusString($status)
    {
        $status = \array_search(\strtolower($status), TicketMessageInterface::STATUSES);

        if ($status > 0) {
            $this->setStatus($status);
        }

        return $this;
    }
1133740
public function setStatus($status)
    {
        if (!in_array(
            $status,
            [
                self::STATUS_OPEN,
                self::STATUS_PAUSED,
                self::STATUS_CLOSED,
                self::STATUS_INTERACTION_REQUIRED,
                self::STATUS_BACKGROUND_PROCESS,
            ]
        )
        ) {
            throw new \InvalidArgumentException('Invalid status in '.get_class($this).'.');
        }

        // If end date is in the past, status is automatically "closed" if status is not "paused".
        if (
            ($status != self::STATUS_BACKGROUND_PROCESS && $status != self::STATUS_CLOSED && $status != self::STATUS_PAUSED && $this->endDate && $this->endDate < new \DateTime(
                    'now'
                ))
            ||
            ($status != self::STATUS_BACKGROUND_PROCESS && $status != self::STATUS_CLOSED && $status != self::STATUS_PAUSED && !$this->endDate && $this->startDate && $this->startDate < new \DateTime(
                    'now'
                ))
        ) {
            // TODO: Warning that status is different from what has been provided.
            $status = self::STATUS_CLOSED;
        }

        $this->status = $status;

        return $this;
    }
441027
public function status($status)
    {
        $httpStatus = (string) $this->response->getStatusCode();
        if (is_array($status) && !in_array($httpStatus, $status)) {
            throw new \RuntimeException(
                "Unexpected response status code: {$httpStatus}"
            );
        }

        if (is_string($status) && $httpStatus !== $status) {
            throw new \RuntimeException(
                "Unexpected response status code: {$httpStatus}"
            );
        }

        return $this;
    }
110286
public function withStatus($code, $reasonPhrase = '')
    {
        if (! isset($this->statusTexts[$code])) {
            throw new \InvalidArgumentException("Invalid status code. [{$code}]");
        }

        $this->statusCode   = $code;
        $this->reasonPhrase = $reasonPhrase ?: $this->statusTexts[$code];

        return $this;
    }
842295
public function setStatus(\Sulu\Bundle\ProductBundle\Entity\Status $status)
    {
        $this->status = $status;

        return $this;
    }
985060
public function setStatus(int $code): Response
    {
        # `Status::getText` will throw an exception for invalid status codes
        $this->statusText = Status::getText($code);
        $this->statusCode = $code;
        return $this;
    }
220128
public function setStatus($status)
    {
        if (!in_array($status, MessageStatus::getValidStatus())) {
            throw new \InvalidArgumentException('短信状态非法');
        }
        $this->status = $status;
    }
402159
public function setStatus($status)
    {
        $allowedValues = $this->getStatusAllowableValues();
        if (!in_array($status, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'status', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['status'] = $status;

        return $this;
    }
1293997
public function setStatus($status)
    {
        if (
            !in_array(
                $status,
                array(
                    self::STATUS_SUCCESS,
                    self::STATUS_ERROR,
                    self::STATUS_FAIL,
                )
            )
        ) {
            throw new Doozr_Base_Response_Rest_Exception(

            );
        }

        $this->status = $status;
    }
237931
public function setLine2($line2)
    {
        if (!is_string($line2) && !is_null($line2)) {
            throw new \InvalidArgumentException(__CLASS__ . ' ' . __METHOD__ . ': Not a string');
        }

        $this->line2 = $line2;

        return $this;
    }
1361885
public function addHeader($headerLine)
    {
        $parts = explode(':', $headerLine, 2);
        if (2 !== count($parts)) {
            throw new \InvalidArgumentException(
                sprintf('"%s" is not a valid HTTP header line', $headerLine)
            );
        }
        $name = trim($parts[0]);
        $value = trim($parts[1]);
        if ($this->response->hasHeader($name)) {
            $this->response = $this->response->withAddedHeader($name, $value);
        } else {
            $this->response = $this->response->withHeader($name, $value);
        }

        return $this;
    }