ellipse/resolvers-abstract

This package is abandoned and no longer maintained. No replacement package was suggested.

The abstract resolver component of the ellipse framework

dev-master / 1.0.x-dev 2017-07-27 13:35 UTC

This package is not auto-updated.

Last update: 2017-08-01 12:39:42 UTC


README

This package provides an abstract middleware resolver.

It allows to easily create new middleware resolvers to be used with an ellipse middleware dispatcher.

Require php >= 7.1

Installation composer require ellipse/resolvers-abstract

Run tests ./vendor/bin/peridot tests

Extending abstract resolver

This package provides a Ellipse\Resolver\AbstractResolver abstract class which can be extended to easily create new resolvers.

It only contains two abstract methods:

  • ->canResolve($element): bool returning whether or not the resolver can resolve the given element into a middleware
  • ->getMiddleware($element): MiddlewareInterface returning a middleware from the given element
<?php

namespace App\Resolvers;

use Interop\Http\ServerMiddleware\MiddlewareInterface;

use Ellipse\Resolvers\AbstractResolver;

class MyResolver extends AbstractResolver
{
    public function canResolve($element): bool
    {
        // return whether the element can be resolved.
    }

    public function getMiddleware($element): MiddlewareInterface
    {
        // return some middleware from $element.
    }
}