PHPackages                             terah/fluent-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. terah/fluent-assert

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

terah/fluent-assert
===================

A light weight assertion package based on beberlei/assert

8.0.1.0(9mo ago)02.5k7MITPHPPHP &gt;=8.0

Since Mar 6Pushed 9mo agoCompare

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

READMEChangelogDependenciesVersions (123)Used By (7)

fluent-assert
=============

[](#fluent-assert)

[![Latest Version](https://camo.githubusercontent.com/2d2273b341a2f4ba6a49963266937665a549d9a422a66588bfa9e8f053d98fbe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f74657261682f666c75656e742d6173736572742e7376673f7374796c653d666c61742d737175617265)](https://github.com/terah/fluent-assert/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/862b2861f42f8bdbf3fa81c978eb087847bc9d474b0be4aac39d3b1e61b8d77e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f74657261682f666c75656e742d6173736572742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/terah/fluent-assert)[![Coverage Status](https://camo.githubusercontent.com/fe27d9f9cc822c2b632f04710f7b2828f3017bd2af0299df4c37b2cc9d610987/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f74657261682f666c75656e742d6173736572742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/terah/fluent-assert/code-structure)[![Quality Score](https://camo.githubusercontent.com/94d1211c8b9f61588fe253ac3e7ab7ae29b7c8addcf32d52eb4d9bda74367bc4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f74657261682f666c75656e742d6173736572742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/terah/fluent-assert)[![Total Downloads](https://camo.githubusercontent.com/c747941f039f6254f931b8c42f2edeee501b669c468b8435824c5c567ecd55f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74657261682f666c75656e742d6173736572742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/terah/fluent-assert)

This is a fork/subset of the awesome package Assert (). I only use the fluent (chained) interface and the assert library is very heavily used chunk of code. By breaking it into it's own library the library is about 3 times faster (using my very unscienctific benchark).

Install
-------

[](#install)

Via Composer

```
$ composer require terah/fluent-assert
```

Usage
-----

[](#usage)

```
use Terah\Assert\Assert;

(new Assert($value))->eq($value2, string $message='', string $fieldName='');
(new Assert($value))->same($value2, string $message='', string $fieldName='');
(new Assert($value))->notEq($value2, string $message='', string $fieldName='');
(new Assert($value))->notSame($value2, string $message='', string $fieldName='');
(new Assert($value))->integer(string $message='', string $fieldName='');
(new Assert($value))->float(string $message='', string $fieldName='');
(new Assert($value))->digit(string $message='', string $fieldName='');
(new Assert($value))->date($message=null, $fieldName=null);
(new Assert($value))->integerish(string $message='', string $fieldName='');
(new Assert($value))->boolean(string $message='', string $fieldName='');
(new Assert($value))->scalar(string $message='', string $fieldName='');
(new Assert($value))->notEmpty(string $message='', string $fieldName='');
(new Assert($value))->noContent(string $message='', string $fieldName='');
(new Assert($value))->notNull(string $message='', string $fieldName='');
(new Assert($value))->string(string $message='', string $fieldName='');
(new Assert($value))->regex($pattern, string $message='', string $fieldName='');
(new Assert($value))->length($length, string $message='', string $fieldName='', $encoding = 'utf8');
(new Assert($value))->minLength($minLength, string $message='', string $fieldName='', $encoding = 'utf8');
(new Assert($value))->maxLength($maxLength, string $message='', string $fieldName='', $encoding = 'utf8');
(new Assert($value))->betweenLength($minLength, $maxLength, string $message='', string $fieldName='', $encoding = 'utf8');
(new Assert($value))->startsWith($needle, string $message='', string $fieldName='', $encoding = 'utf8');
(new Assert($value))->endsWith($needle, string $message='', string $fieldName='', $encoding = 'utf8');
(new Assert($value))->contains($needle, string $message='', string $fieldName='', $encoding = 'utf8');
(new Assert($value))->choice(array $choices, string $message='', string $fieldName='');
(new Assert($value))->inArray(array $choices, string $message='', string $fieldName='');
(new Assert($value))->numeric(string $message='', string $fieldName='');
(new Assert($value))->isArray(string $message='', string $fieldName='');
(new Assert($value))->isTraversable(string $message='', string $fieldName='');
(new Assert($value))->isArrayAccessible(string $message='', string $fieldName='');
(new Assert($value))->keyExists($key, string $message='', string $fieldName='');
(new Assert($value))->keysExist($keys, string $message='', string $fieldName='');
(new Assert($value))->propertyExists($key, string $message='', string $fieldName='');
(new Assert($value))->propertiesExist(array $keys, string $message='', string $fieldName='');
(new Assert($value))->utf8(string $message='', string $fieldName='');
(new Assert($value))->keyIsset($key, string $message='', string $fieldName='');
(new Assert($value))->notEmptyKey($key, string $message='', string $fieldName='');
(new Assert($value))->notBlank(string $message='', string $fieldName='');
(new Assert($value))->isInstanceOf($className, string $message='', string $fieldName='');
(new Assert($value))->notIsInstanceOf($className, string $message='', string $fieldName='');
(new Assert($value))->subclassOf($className, string $message='', string $fieldName='');
(new Assert($value))->range($minValue, $maxValue, string $message='', string $fieldName='');
(new Assert($value))->min($minValue, string $message='', string $fieldName='');
(new Assert($value))->max($maxValue, string $message='', string $fieldName='');
(new Assert($value))->file(string $message='', string $fieldName='');
(new Assert($value))->directory(string $message='', string $fieldName='');
(new Assert($value))->readable(string $message='', string $fieldName='');
(new Assert($value))->writeable(string $message='', string $fieldName='');
(new Assert($value))->email(string $message='', string $fieldName='');
(new Assert($value))->url(string $message='', string $fieldName='');
(new Assert($value))->alnum(string $message='', string $fieldName='');
(new Assert($value))->true(string $message='', string $fieldName='');
(new Assert($value))->false(string $message='', string $fieldName='');
(new Assert($value))->classExists(string $message='', string $fieldName='');
(new Assert($value))->implementsInterface($interfaceName, string $message='', string $fieldName='');
(new Assert($value))->isJsonString(string $message='', string $fieldName='');
(new Assert($value))->uuid(string $message='', string $fieldName='');
(new Assert($value))->samAccountName(string $message='', string $fieldName='');
(new Assert($value))->unc(string $message='', string $fieldName='');
(new Assert($value))->driveLetter(string $message='', string $fieldName='');
(new Assert($value))->userPrincipalName(string $message='', string $fieldName='');
(new Assert($value))->count($count, string $message='', string $fieldName='');
(new Assert($value))->choicesNotEmpty(array $choices, string $message='', string $fieldName='');
(new Assert($value))->methodExists($object, string $message='', string $fieldName='');
(new Assert($value))->isObject(string $message='', string $fieldName='');

// Chaining
(new Assert($myValue))->integer()->notEmpty()->eq(1);

// Checking members of arrays and objects)
(new Assert($myArray))->all()->integer()->notEmpty()->eq(1);

// Null or valid
(new Assert($myNullValue)->nullOr()->integer()->notEmpty()->eq(1);

// Reset the all and nullOr flags and set value
(new Assert($value))->reset($value)
// Set a new value
(new Assert($value))->value($value)
// Set the null or flag
(new Assert($value))->nullOr($nullOr=true)
// Set the all flag
(new Assert($value))->all($all=true)
// Set the exception class
(new Assert($value))->setExceptionClass('\\My\\Exception\\Class');
```

Testing
-------

[](#testing)

```
$ bin/tester tests/
```

Please see tests/AssertSuite.php for example of writing tests

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Terry Cullen](https://github.com/terah)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance58

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 63.8% 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 ~31 days

Recently: every ~420 days

Total

122

Last Release

271d ago

Major Versions

1.0.7.4 → 2.0.02017-02-06

2.0.0.4 → 3.0.0.02018-02-01

3.0.0.9 → 4.0.0.52018-05-04

4.0.7.6 → 6.0.0.52021-01-14

6.0.1.0 → 8.0.0.02025-08-20

PHP version history (4 changes)0.1PHP &gt;=5.3.0

2.0.0.1PHP &gt;=7.0

6.0.0.5PHP &gt;=7.4

8.0.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/13de50ce12f8fef19ca345899735b089bd9a535aaf93d1f40eacb9726c60cd0e?d=identicon)[terah](/maintainers/terah)

---

Top Contributors

[![terah](https://avatars.githubusercontent.com/u/2120322?v=4)](https://github.com/terah "terah (74 commits)")[![johnnyreid](https://avatars.githubusercontent.com/u/31675862?v=4)](https://github.com/johnnyreid "johnnyreid (23 commits)")[![uqcullen](https://avatars.githubusercontent.com/u/65157728?v=4)](https://github.com/uqcullen "uqcullen (19 commits)")

---

Tags

terahfluent-assert

### Embed Badge

![Health badge](/badges/terah-fluent-assert/health.svg)

```
[![Health](https://phpackages.com/badges/terah-fluent-assert/health.svg)](https://phpackages.com/packages/terah-fluent-assert)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)

PHPackages © 2026

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