PHPackages                             php-addons/bc-assert - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. php-addons/bc-assert

ActiveLibrary[Testing &amp; Quality](/categories/testing)

php-addons/bc-assert
====================

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

0.1.9(5y ago)0631MITPHPPHP ^7.3 || ^8.0

Since Sep 6Pushed 5y agoCompare

[ Source](https://github.com/php-addons/bc-assert)[ Packagist](https://packagist.org/packages/php-addons/bc-assert)[ Docs](https://github.com/php-addons/bc-assert)[ RSS](/packages/php-addons-bc-assert/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (11)Used By (0)

Bcmath Assert
=============

[](#bcmath-assert)

[![Build Status](https://camo.githubusercontent.com/50978bd5bd2f038d02b84e73bd261c2f182260d54d4eabfde0786b4e1c200f8b/68747470733a2f2f7472617669732d63692e6f72672f7068702d6164646f6e732f62632d6173736572742e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/github/php-addons/bc-assert)

A wrapper around [webmozart/assert](https://github.com/webmozart/assert) that implements assertions with [bcmath](https://www.php.net/manual/en/ref.bc.php) functions.

**Required PHP 7.3.0 or above.**

Installation
------------

[](#installation)

```
composer require php-addons/bc-assert
```

How to use
----------

[](#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
----------

[](#assertions)

The \[`Assert`\] class provides the following assertions:

### Comparison Assertions

[](#comparison-assertions)

MethodDescription`bcSame($value, $value2, $message = '', $scale = null)`Check that a value is identical to another (`bccomp($value, $value2, $scale) === 0`)`bcNotSame($value, $value2, $message = '', $scale = null)`Check that a value is not identical to another (`bccomp($value, $value2, $scale) !== 0`)`bcGreaterThan($value, $value2, $message = '', $scale = null)`Check that a value is greater than another`bcGreaterThanEq($value, $value2, $message = '', $scale = null)`Check that a value is greater than or equal to another`bcLessThan($value, $value2, $message = '', $scale = null)`Check that a value is less than another`bcLessThanEq($value, $value2, $message = '', $scale = null)`Check that a value is less than or equal to another`bcRange($value, $min, $max, $message = '', $scale = null)`Check that a value is within a range

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Recently: every ~15 days

Total

10

Last Release

2021d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3952b6141e47b5a2423e70ba3b83a674b19085e11e380e4abe243f293907f440?d=identicon)[vyacheslav-startsev](/maintainers/vyacheslav-startsev)

---

Top Contributors

[![vyacheslav-startsev](https://avatars.githubusercontent.com/u/25704924?v=4)](https://github.com/vyacheslav-startsev "vyacheslav-startsev (12 commits)")

---

Tags

assertbcmathwebmozart

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/php-addons-bc-assert/health.svg)

```
[![Health](https://phpackages.com/badges/php-addons-bc-assert/health.svg)](https://phpackages.com/packages/php-addons-bc-assert)
```

###  Alternatives

[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69617.9M510](/packages/spatie-phpunit-snapshot-assertions)[peridot-php/leo

Next level assertion and matcher library for PHP

36366.4k50](/packages/peridot-php-leo)[elliotchance/concise

Concise is test framework for using plain English and minimal code, built on PHPUnit.

45223.8k4](/packages/elliotchance-concise)[meyfa/phpunit-assert-gd

PHPUnit matcher/assertions for GD image resources

12553.6k12](/packages/meyfa-phpunit-assert-gd)[respect/assertion

The power of Respect\\Validation into an assertion library

2828.0k](/packages/respect-assertion)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
