tabuna/failback

Small wrapper for creating a branch of inaccessibility

2.0 2020-01-08 03:17 UTC

This package is auto-updated.

Last update: 2020-05-08 04:02:37 UTC


README

68747470733a2f2f7472617669732d63692e6f72672f746162756e612f6661696c6261636b2e7376673f6272616e63683d6d6173746572 Packagist Packagist Version

This is a small wrapper for creating a branch of inaccessibility.

Install

Via Composer

$ composer require tabuna/failback

Usage

Default Value:

use Tabuna\FailBack\Action;

// $result = 'default';
$result = Action::make(function () {
    throw new \Exception();
}, 'default')->run();

// or short helper
$result = failBack(function (){
    throw new \Exception();
}, 'default')();

Fallback Features:

// $result = true;
$result = failBack(function () {
    throw new \Exception();
})->fail(function () {
    throw new \Error();
})->fail(function () {
    return true;
})();

As classes:

$class = new class {

    /**
     * @return bool
     */
    public function __invoke(): bool
    {
        return true;
    }
};

// $result = true;
$result = failBack(function () {
    throw new Exception();
})->fail($class)->run();

Testing

$ composer test

License

The MIT License (MIT). Please see License File for more information.