php-addons/bc-assert

A wrapper around webmozart/assert that implements assertions with bcmath functions.

0.1.9 2020-11-04 17:29 UTC

This package is auto-updated.

Last update: 2024-11-05 02:23:13 UTC


README

Build Status

A wrapper around webmozart/assert that implements assertions with bcmath functions.

Required PHP 7.3.0 or above.

Installation

composer require php-addons/bc-assert

How to use

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);
    }
}

If the last parameter ($scale) is not set, the default scale from the system will be used.

Assertions

The [Assert] class provides the following assertions:

Comparison Assertions