Class ResponseValidator
HTTP response validator helper class.
Methods summary
public
|
#
__construct( Psr\Http\Message\ResponseInterface $response )
Constructs a response validator instance.
Constructs a response validator instance.
Parameters
- $response
- Response to validate
|
public
Psr\Http\Message\ResponseInterface
|
#
getResponse( )
Gets the response object.
Gets the response object.
Returns
Psr\Http\Message\ResponseInterface
|
public
Klarna\Rest\Transport\ResponseValidator
|
#
status( string|string[] $status )
Asserts the HTTP response status code.
Asserts the HTTP response status code.
Parameters
- $status
- Expected status code(s)
Returns
Throws
RuntimeException If status code does not match
|
public
Klarna\Rest\Transport\ResponseValidator
|
#
contentType( string $mediaType )
Asserts the Content-Type header.
Asserts the Content-Type header.
Parameters
- $mediaType
- Expected media type
Returns
Throws
RuntimeException If Content-Type header is missing
RuntimeException If Content-Type header does not match
|
public
array
|
#
getJson( )
Get the decoded JSON response.
Get the decoded JSON response.
Returns
array
Throws
RuntimeException If the response body is not in JSON format
InvalidArgumentException If the JSON cannot be parsed
|
public
string
|
#
getLocation( )
Gets the Location header.
Gets the Location header.
Returns
string
Throws
RuntimeException If the Location header is missing
|
Magic methods summary
Properties summary
protected
Psr\Http\Message\ResponseInterface
|
$response
HTTP response to validate against.
HTTP response to validate against.
|
|