public function setStatusCode($status, $reason = null)
{
if ($this->_httpHeaderSent) {
throw new \Exception('Unable to alter response as HTTP header already sent');
}
$status = TPropertyValue::ensureInteger($status);
if (isset(self::$HTTP_STATUS_CODES[$status])) {
$this->_reason = self::$HTTP_STATUS_CODES[$status];
} else {
if ($reason === null || $reason === '') {
throw new TInvalidDataValueException("response_status_reason_missing");
}
$reason = TPropertyValue::ensureString($reason);
if (strpos($reason, "\r") != false || strpos($reason, "\n") != false) {
throw new TInvalidDataValueException("response_status_reason_barchars");
}
$this->_reason = $reason;
}
$this->_status = $status;
}