tomphp/exception-constructor-tools
最新稳定版本:v2.0.0
Composer 安装命令:
composer require tomphp/exception-constructor-tools
包简介
A simple PHP trait which makes creating static constructors for exceptions nicer.
README 文档
README
A simple PHP trait which makes creating static constructors for exceptions nicer.
Installation
$ composer require tomphp/exception-constructor-tools
Usage
Define your exception:
<?php use TomPHP\ExceptionConstructorTools\ExceptionConstructorTools; class MyExceptionClass extends \RuntimeException { use ExceptionConstructorTools; public static function forEntity($entity) { return self::create( 'There was an error with an entity of type %s with value of %s.', [ self::typeToString($entity) self::valueToString($entity) ] ); } }
Throw your exception:
if ($errorOccurred) { throw MyExceptionClass::forEntity($entity); }
统计信息
- 总下载量: 41.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-08