承接 bentools/psr7-request-matcher 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bentools/psr7-request-matcher

最新稳定版本:1.1

Composer 安装命令:

composer require bentools/psr7-request-matcher

包简介

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

README 文档

README

Latest Stable Version License Build Status Total Downloads

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.

These interfaces provide no return type-hint and is therefore compatible from PHP 5.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

Tests

./vendor/bin/phpunit

统计信息

  • 总下载量: 307.39k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-11