2017 © Pedro PelĂĄez
 

library reaction

Library for dealing with reactions of actions

image

aaronmacaron/reaction

Library for dealing with reactions of actions

  • Sunday, April 15, 2018
  • by Aaronmacaron
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Reaction Library

Travis Packagist, (*1)

This library makes it easy to handle reactions of actions, methods and functions. If you are dealing with methods that can either be successful or fail and want more information about the result of the method, you can use a reaction., (*2)

Installation

You can install reaction using Composer:, (*3)

$ composer require aaronmacaron/reaction

To install and use the reaction library you need PHP version 7.1 or newer., (*4)

Example

You can use this library as follows:, (*5)

<?php

use Aaronmacaron\Reaction\Reaction;

include __DIR__ . "/vendor/autoload.php";

function validatePassword(string $password): Reaction
{
    if (empty($password)) {
        return Reaction::failure("The password must not be empty!");
    }

    if (strlen($password) >= 8) {
        return Reaction::success();
    }

    return Reaction::failure("The password must be at least eight chars long.");
}

validatePassword("secret")
    ->succeed(function () {
        echo "Password is valid" . PHP_EOL;
    })->fail(function (Reaction $reaction) {
        echo "The password is not valid: " . $reaction->getMessage() . PHP_EOL;
    });

// Output: The password is not valid: The password must be at least eight chars long.

The Versions

15/04 2018

dev-dev

dev-dev

Library for dealing with reactions of actions

  Sources   Download

The Requires

  • php >=7.1

 

The Development Requires

by Aaron Ebnöther

15/04 2018

dev-master

9999999-dev

Library for dealing with reactions of actions

  Sources   Download

The Requires

  • php >=7.1

 

The Development Requires

by Aaron Ebnöther

15/04 2018

0.1.1

0.1.1.0

Library for dealing with reactions of actions

  Sources   Download

The Requires

  • php >=7.1

 

The Development Requires

by Aaron Ebnöther

14/04 2018

0.1.0

0.1.0.0

Library for dealing with reactions of actions

  Sources   Download

The Development Requires

by Aaron Ebnöther