定制 try/predict-exception 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

try/predict-exception

Composer 安装命令:

composer require try/predict-exception

包简介

Simplified predictions if a piece of codes throws an Exception

README 文档

README

Simplified predictions if a piece of codes throws an Exception

Build Status

Install

$ composer require try/predict-exception

Usage

<?php
require_once '/path/to/autoload.php';

use TryPhp\PredictExeptionTrait;

$assertions = new class() {
	use PredictExeptionTrait();
} 

$assertions->predictException(function () {
	throw new \RuntimeException('Oooops. Something broke.')
}, \RuntimeException::class); // won't throw an exception

$assertions->predictException(function () {
}, \Exception::class); // will throw an exception

$assertions->predictException(function () {
	throw new \RuntimeException('something else happened.');
}, \Exception::class); // will throw an exception

API

Methods

predictException($capture, $exceptionClass)

Method to check if a given piece of code throws an Throwable of the expected type.

Arguments
Arguments Type Description
$capture callable Closure in which the Throwable shall be thrown.
$exceptionClass string Class of the Throwable that is expected to be thrown.

License

GPL-2.0 © Willi Eßer

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2017-10-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固