pock

PockResponseBuilder
in package
Uses JsonSerializerAwareTrait, XmlSerializerAwareTrait

Class PockResponseBuilder

Tags
category

PockResponseBuilder

Table of Contents

__construct()  : mixed
PockResponseBuilder constructor.
getResponse()  : ResponseInterface
withAddedHeader()  : self
Respond with specified header pattern appended to existing header.
withAddedHeaders()  : self
Respond with specified headers. Works exactly like calling PockResponseBuilder::withAddedHeader() would work.
withBody()  : self
Reply with specified body. It can be: - PSR-7 StreamInterface - it will be used without any changes.
withFile()  : self
Reply with data from specified file.
withHeader()  : self
Respond with specified header pattern.
withHeaders()  : self
Respond with specified headers. Works exactly like calling PockResponseBuilder::withHeader() would work.
withJson()  : self
withStatusCode()  : self
Reply with specified status code.
withXml()  : self

Methods

__construct()

PockResponseBuilder constructor.

public __construct([int $statusCode = 200 ]) : mixed
Parameters
$statusCode : int = 200
Return values
mixed

getResponse()

public getResponse() : ResponseInterface
Return values
ResponseInterface

withAddedHeader()

Respond with specified header pattern appended to existing header.

public withAddedHeader(string $name, string|array<string|int, string> $value) : self
Parameters
$name : string
$value : string|array<string|int, string>
Tags
see
MessageInterface::withAddedHeader()
Return values
self

withAddedHeaders()

Respond with specified headers. Works exactly like calling PockResponseBuilder::withAddedHeader() would work.

public withAddedHeaders(array<string, string|string[]> $headers) : self
Parameters
$headers : array<string, string|string[]>
Return values
self

withBody()

Reply with specified body. It can be: - PSR-7 StreamInterface - it will be used without any changes.

public withBody(StreamInterface|resource|string $stream) : self
  • string - it will be used as contents contents.
  • resource - it's data will be used as contents contents.
Parameters
$stream : StreamInterface|resource|string
Return values
self

withFile()

Reply with data from specified file.

public withFile(string $path[, string $mode = 'r' ]) : self

For available modes @see \fopen()

Parameters
$path : string
$mode : string = 'r'
Tags
throws
InvalidArgumentException|RuntimeException
Return values
self

withHeader()

Respond with specified header pattern.

public withHeader(string $name, string|array<string|int, string> $value) : self
Parameters
$name : string
$value : string|array<string|int, string>
Tags
see
MessageInterface::withHeader()
Return values
self

withHeaders()

Respond with specified headers. Works exactly like calling PockResponseBuilder::withHeader() would work.

public withHeaders(array<string, string|string[]> $headers) : self
Parameters
$headers : array<string, string|string[]>
Return values
self

withStatusCode()

Reply with specified status code.

public withStatusCode([int $statusCode = 200 ]) : self
Parameters
$statusCode : int = 200
Return values
self

Search results