2017 © Pedro Peláez
 

library psr7-request-matcher

A PSR-7 RequestMatcher interface for use into several projects.

image

bentools/psr7-request-matcher

A PSR-7 RequestMatcher interface for use into several projects.

  • Wednesday, March 7, 2018
  • by bpolaszek
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,428 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 101 % Grown

The README.md

Latest Stable Version License Build Status Total Downloads, (*1)

PSR-7 Request Matcher

This library is just composed of interfaces to implement, to check wether or not a request and/or a response match some arbitrary conditions., (*2)

These interfaces provide no return type-hint and is therefore compatible from PHP 5.3+., (*3)

Examples

Request matcher

namespace App;

use BenTools\Psr7\RequestMatcherInterface;
use Psr\Http\Message\RequestInterface;

class ExampleOrgRequestMatcher implements RequestMatcherInterface
{
    /**
     * @inheritdoc
     */
    public function matchRequest(RequestInterface $request)
    {
        return 'www.example.org' === $request->getUri()->getHost();
    }

}

Response matcher

namespace App;

use BenTools\Psr7\ResponseMatcherInterface;
use Psr\Http\Message\ResponseInterface;

class TeapotResponseMatcher implements ResponseMatcherInterface
{
    /**
     * @inheritdoc
     */
    public function matchResponse(ResponseInterface $response)
    {
        return 418 === $response->getStatusCode();
    }

}

Transfer matcher

namespace App;

use BenTools\Psr7\TransferMatcherInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

class DummyTransferMatcher implements TransferMatcherInterface
{
    /**
     * @inheritdoc
     */
    public function matchTransfer(RequestInterface $request, ResponseInterface $response)
    {
        return $request->hasHeader('Authorization')
            && 'Welcome, human.' === (string) $response->getBody();
    }

}

Installation

composer require bentools/psr7-request-matcher, (*4)

Tests

./vendor/bin/phpunit, (*5)

The Versions

07/03 2018

dev-master

9999999-dev

A PSR-7 RequestMatcher interface for use into several projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar bpolaszek

07/03 2018

1.1

1.1.0.0

A PSR-7 RequestMatcher interface for use into several projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar bpolaszek

12/07 2017

1.0

1.0.0.0

A PSR-7 RequestMatcher interface for use into several projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar bpolaszek