public function setCode($code)
    {
        $code = (int)$code;

        if (!empty($this->body) && !HttpCode::isBodyAllowed($code)) { //InvalidArgumentException can be thrown here
            throw new LogicException('HTTP response already contains body - response "' . HttpCode::getName($code) . '" cannot contain body.');
        }

        $this->code = $code;
        $this->messageCache = null;
    }