kherge/exception

简化使用格式化消息构建新异常的过程。

1.0.0 2018-02-21 04:22 UTC

This package is auto-updated.

Last update: 2024-09-10 14:38:56 UTC


README

Build Status Quality Gate

异常

简化使用格式化消息构建新异常的过程。

使用方法

use KHerGe\Exception\AbstractException;

class MyException extends AbstractException
{
}

// Without any arguments.
$exception = new MyException();

// With only a message. ("Example message.")
$exception = new MyException('Example message.');

// With a message format and values to format. ("Example message.")
$exception = new MyException('Example %s.', 'message');

// With only a previous exception.
$exception = new MyException($previous);

// With a message and previous exception.
$exception = new MyException('Example message.', $previous);

// With a message format, values to format, and a previous exception.
$exception = new MyException('Example %s.', 'message', $previous);

要求

  • PHP 7.1 或更高版本

安装

使用 Composer 将包作为依赖项安装。

$ composer require kherge/exception

测试

使用 PHPUnit 7.0 运行测试套件。

$ phpunit

许可证

此库可在 Apache 2.0 和 MIT 许可证下使用。