承接 tabuna/failback 相关项目开发

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

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

tabuna/failback

Composer 安装命令:

composer require tabuna/failback

包简介

Small wrapper for creating a branch of inaccessibility

README 文档

README

Actions for Failback is a lightweight wrapper that empowers you to handle unavailability gracefully.

Installation

To install the package, you can use Composer. Simply run the following command:

$ composer require tabuna/failback

Usage

Setting a Default Value:

You can create an action with a default value using the following code:

use Tabuna\FailBack\Action;

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

// Alternatively, you can use the short helper
$result = failBack(function () {
    throw new \Exception();
}, 'default')();

Adding Fallback Actions:

You can define multiple fallback actions using the fail method:

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

Utilizing Classes:

To specify a fallback action using a class, create an anonymous class with an __invoke method:

$class = new class {

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

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

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固