n1215/http-request-matcher

Matcher interface for PSR-7 HTTP request, like preg_match() for string.

v1.0.0 2017-12-08 10:00 UTC

This package is auto-updated.

Last update: 2024-12-11 21:59:46 UTC


README

Latest Stable Version License Build Status Code Coverage Scrutinizer Code Quality

Matcher interface for PSR-7 HTTP request, like preg_match() for string.

Usage

// 1. implement RequestMatcherInterface or ServerRequestMatcherInterface. you can use RequestMatchResult concrete class.

class YourServerRequestMatcher implements ServerRequestMatcherInterface
{
    public function match(ServerRequestInterface $request): RequestMatchResultInterface
    {
        // implement
    }
}

// 2. use for PSR-7 Request
$matcher = new YourServerRequestMatcher();

/** @var \Psr\Http\Message\ServerRequestInterface $request */
$result = $matcher->match($request);

if ($result->isSuccess()) {
    var_dump($result->getParams());
}

Implementation examples

Class diagram

request-matcher