PHP Class Psr7Middlewares\Middleware\JsonValidator

Show file Open project: oscarotero/psr7-middlewares Class Usage Examples

Public Methods

Method Description
__construct ( stdClass $schema ) JsonSchema constructor.
__invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface Execute the middleware.
fromArray ( array $json ) : static | callable
fromDecodedObject ( stdClass $schema ) : static | callable
fromEncodedString ( string $json ) : static | callable
fromFile ( SplFileObject $file ) : static | callable

Private Methods

Method Description
invalidateResponse ( Psr\Http\Message\ResponseInterface $response, string $reason, array $headers = [], string | null $body = null ) : Psr\Http\Message\ResponseInterface

Method Details

__construct() public method

Consider using one of the following factories instead of invoking the controller directly: - JsonValidator::fromFile() - JsonValidator::fromEncodedString() - JsonValidator::fromDecodedObject() - JsonValidator::fromArray()
public __construct ( stdClass $schema )
$schema stdClass A JSON-decoded object-representation of the schema.

__invoke() public method

Execute the middleware.
public __invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$next callable
return Psr\Http\Message\ResponseInterface

fromArray() public static method

public static fromArray ( array $json ) : static | callable
$json array
return static | callable

fromDecodedObject() public static method

public static fromDecodedObject ( stdClass $schema ) : static | callable
$schema stdClass
return static | callable

fromEncodedString() public static method

public static fromEncodedString ( string $json ) : static | callable
$json string
return static | callable

fromFile() public static method

public static fromFile ( SplFileObject $file ) : static | callable
$file SplFileObject
return static | callable