php-addons/bc-assert

webmozart/assert 的包装器,实现了使用 bcmath 函数的断言。

0.1.9 2020-11-04 17:29 UTC

This package is auto-updated.

Last update: 2024-09-05 01:59:08 UTC


README

Build Status

webmozart/assert 的包装器,实现了使用 bcmath 函数的断言。

需要 PHP 7.3.0 或更高版本。

安装

composer require php-addons/bc-assert

如何使用

use PhpAddons\BcAssert\Assert;

class Money
{
    public function __construct(string $value)
    {
        Assert::bcGreaterThan($value, '0', 'The money must be a positive number. Got: %s', 2);
    }
}

如果最后一个参数($scale)未设置,将使用系统默认的比例。

断言

Assert 类提供以下断言

比较断言