Naify\Psr\Contract\ResponseInterface インターフェース

implements Naify\Psr\Contract\MessageInterface

レスポンスインターフェース — PSR-7 ResponseInterface 相当

ステータスコード、理由フレーズ、ヘッダー、ボディを保持する。 すべての with*() メソッドは元インスタンスを変更せず、新しいレスポンスを返す。

使用例

$response = $response
    ->withStatus(201)
    ->withHeader('Content-Type', 'application/json');

メソッド

メソッド説明
public getStatusCode(): int HTTP ステータスコード (200, 404 等) を返す
public withStatus(int $code, string $reasonPhrase = ): static ステータスコードを差し替えた新インスタンスを返す
public getReasonPhrase(): string ステータスの理由フレーズ ("OK", "Not Found" 等) を返す

継承メソッド

メソッド説明継承元
public getProtocolVersion(): string HTTP プロトコルバージョンを返す MessageInterface
public withProtocolVersion(): static HTTP プロトコルバージョンを変更した新しいインスタンスを返す MessageInterface
public getHeaders(): array すべてのヘッダーを返す MessageInterface
public hasHeader(): bool 指定したヘッダーが存在するか判定する MessageInterface
public getHeader(): array 指定したヘッダーの値一覧を返す MessageInterface
public getHeaderLine(): string 指定したヘッダーを 1 行文字列として返す MessageInterface
public withHeader(): static ヘッダーを置き換えた新しいインスタンスを返す MessageInterface
public withAddedHeader(): static ヘッダー値を追加した新しいインスタンスを返す MessageInterface
public withoutHeader(): static 指定したヘッダーを除外した新しいインスタンスを返す MessageInterface
public getBody(): StreamInterface メッセージボディのストリームを返す MessageInterface
public withBody(): static メッセージボディを差し替えた新しいインスタンスを返す MessageInterface