Raml\Validator\ValidatorSchemaHelper::getResponseBody PHP Метод

getResponseBody() публичный Метод

public getResponseBody ( string $method, string $path, integer $statusCode, string $contentType ) : Raml\Body
$method string
$path string
$statusCode integer
$contentType string
Результат Raml\Body
    public function getResponseBody($method, $path, $statusCode, $contentType)
    {
        $schema = $this->getResponse($method, $path, $statusCode);
        return $this->getBody($schema, $method, $path, $contentType);
    }

Usage Example

 /**
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @throws ValidatorResponseException
  */
 private function assertValidBody(RequestInterface $request, ResponseInterface $response)
 {
     $method = $request->getMethod();
     $path = $request->getUri()->getPath();
     $statusCode = $response->getStatusCode();
     $contentType = $response->getHeaderLine('Content-Type');
     $schemaBody = $this->schemaHelper->getResponseBody($method, $path, $statusCode, $contentType);
     $body = $response->getBody()->getContents();
     try {
         $schemaBody->getSchema()->validate($body);
     } catch (InvalidSchemaException $exception) {
         $message = sprintf('Response body for %s %s with content type %s and status code %s does not match schema: %s', strtoupper($method), $path, $contentType, $statusCode, $this->getSchemaErrorsAsString($exception->getErrors()));
         throw new ValidatorResponseException($message, 0, $exception);
     }
 }