2017 © Pedro Peláez
 

library decision-pipeline

Simple Middleware-type method of making decisions

image

nathansalter/decision-pipeline

Simple Middleware-type method of making decisions

  • Tuesday, May 31, 2016
  • by nathansalter
  • Repository
  • 1 Watchers
  • 1 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

decision-pipeline

Middleware-esque way of making decisions instead of using Event Managers, (*1)

Usage

Usage of this is very simple. Providing the pipeline a question object, to decide on will pass this question through to all of the decision actors (deciders). Each decider in turn chooses to either make an ultimate decision or make a decision which may be overridden at a later stage., (*2)

Example

Preferable usage is to create your own Question and Decision classes, but if using PHP7 then you MAY use anonymous classes. Deciders passed into the Pipeline MUST either implement PipelineDecider or be a closure., (*3)

$pipeline = new DecisionPipeline([
    function (Question $question, Decision $decision, callable $next = null) {
        if($question->cannot()) {
            throw new \RuntimeException('I cannot!');
        }
        return $next($question, $decision);
    },
    new SpecialDecider()
]);
$decision = $pipeline->decide(new SpecialQuestion());

If no decision is made, the NoDecision class will be returned. You MAY return a custom default decision by simply passing it in as the second parameter to the constructor., (*4)

$pipeline = new DecisionPipeline([], new SpecialDefaultDecision());

Each decider is ALWAYS run in order that it is passed into the constructor, so any priority MUST be set in the constructor., (*5)

The Versions

31/05 2016

dev-php7

dev-php7

Simple Middleware-type method of making decisions

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

25/05 2016

dev-master

9999999-dev

Simple Middleware-type method of making decisions

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

25/05 2016

0.1.0

0.1.0.0

Simple Middleware-type method of making decisions

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires