PHPackages                             simplesamlphp/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. simplesamlphp/assert

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

simplesamlphp/assert
====================

A wrapper around webmozart/assert to make it useful beyond checking method arguments

v2.0.2(2mo ago)77.9M—4.9%3[1 issues](https://github.com/simplesamlphp/assert/issues)20LGPL-2.1-or-laterPHPPHP ^8.3CI passing

Since Jun 11Pushed 1mo ago4 watchersCompare

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

READMEChangelog (1)Dependencies (6)Versions (84)Used By (20)

Assert
======

[](#assert)

[![Build Status](https://github.com/simplesamlphp/assert/actions/workflows/php.yml/badge.svg)](https://github.com/simplesamlphp/assert/actions/workflows/php.yml/badge.svg)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8759362721b1786a3a40e819698f09cff631998daeea5a2761135e381a5b231c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73696d706c6573616d6c7068702f6173736572742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/simplesamlphp/assert/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/22550b6468bbf19599fa7aed1d021b154f2fcf8485658b194310c1bba848be5a/68747470733a2f2f636f6465636f762e696f2f67682f73696d706c6573616d6c7068702f6173736572742f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/simplesamlphp/assert)[![PHPStan Enabled](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/simplesamlphp/assert)

Background
----------

[](#background)

A wrapper around webmozart/assert to make it useful beyond checking method arguments. One of the major reasons to come up with this fork was our requirement to be able to throw custom exceptions, instead of *everything*being thrown as a generic `InvalidArgumentException`.

Using a `__callStatic` wrapper we are able to wrap the webmozart-methods allowing for an extra `exception` parameter, and catch the `InvalidArgumentException` by the original library, then throw the desired exception, or fall back to our custom `AssertionFailedException`.

In practise, this means that *every* assertion provided by the original library can be used an provided with an additional parameter. If you provide it, and it translates into a `Throwable` class, that is what will be thrown as soon as the assertion fails. If you don't pass the the extra parameter, we will throw the more generic `AssertionFailedException` (which in our opinion is still better than the even *more* generic `InvalidArgumentException`).

We also felt that `InvalidArgumentException` is incorrect to use in this case. This exception was intended by PHP to be thrown when a function parameter is of the wrong type. Our custom `AssertionFailedException` therefore inherits from `UnexpectedValueException` which is intended to verify values against valid value sets, possibly during the internal computations of a function. We deem this much more appropriate for use in assertions.

Custom Assertions
-----------------

[](#custom-assertions)

Another reason to fork is the ability to add a few custom assertions that may only make sense for XML / SAML2 related things.

Currently this library provides the following additional assertions:

### Assertions

[](#assertions)

MethodDescription`stringPlausibleBase64($value, $message = '', ?Throwable $exception = null)`Check that a value is plausibly base64`validDateTime($value, $message = '', ?Throwable $exception = null)`Check that a value is a valid ISO8601 compliant DateTime`notInArray($value, $values, $message = '', ?Throwable $exception = null)`Check that a value is *NOT* one of a list of values`validURI($value, $message = '', ?Throwable $exception = null)`Check that a value is a valid RFC3986 URI`validURL($value, $message = '', ?Throwable $exception = null)`Check that a value is a valid RFC2396 URL`validURN($value, $message = '', ?Throwable $exception = null)`Check that a value is a valid RFC8141 URN`validNCName($value, $message = '', ?Throwable $exception = null)`Check that a value is a valid xs:NCName`validQName($value, $message = '', ?Throwable $exception = null)`Check that a value is a valid xs:QName`validDuration($value, $message = '', ?Throwable $exception = null)`Check that a value is a xs:duration`validNMTokens($value, $message = '', ?Throwable $exception = null)`Check that a value is a xs:NMTokens`validNMToken($value, $message = '', ?Throwable $exception = null)`Check that a value is a xs:NMToken`validHexBinary($value, $message = '', ?Throwable $exception = null)`Check that a value is a xs:hexBinary

###  Health Score

67

—

FairBetter than 100% of packages

Maintenance85

Actively maintained with recent releases

Popularity51

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 90.7% 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 ~27 days

Recently: every ~35 days

Total

79

Last Release

61d ago

Major Versions

v0.8.0 → v1.0.02022-09-22

v1.8.3 → v2.0.02026-02-03

PHP version history (8 changes)v0.0.1PHP ^5.6 || ^7.0

v0.0.12PHP ^7.1

v0.0.13PHP ^7.1 || ^8.0

v0.1.0PHP ^7.4 || ^8.0

v1.0.0PHP ^8.0

v1.1.0PHP ^8.1

v1.9.0PHP ^8.2

v2.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/579a16ea8afccc6ab420c393f0e573296fe46dcd293aa4f3b71eefc158ebf3e4?d=identicon)[jaime](/maintainers/jaime)

![](https://www.gravatar.com/avatar/9221e348303eeda74e85236a8bff9b919a90d10e3a478fe1cbb9d833f68d0150?d=identicon)[thijskh](/maintainers/thijskh)

![](https://www.gravatar.com/avatar/d424231c85138609ae230ccd5002c8025fd5dce7f51b2f1778f69ba3a49a4efa?d=identicon)[tvdijen](/maintainers/tvdijen)

---

Top Contributors

[![tvdijen](https://avatars.githubusercontent.com/u/841045?v=4)](https://github.com/tvdijen "tvdijen (273 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (20 commits)")[![jaimeperez](https://avatars.githubusercontent.com/u/1942728?v=4)](https://github.com/jaimeperez "jaimeperez (7 commits)")[![pradtke](https://avatars.githubusercontent.com/u/932934?v=4)](https://github.com/pradtke "pradtke (1 commits)")

### Embed Badge

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

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

###  Alternatives

[phpdocumentor/reflection-docblock

With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.

9.4k722.2M1.2k](/packages/phpdocumentor-reflection-docblock)[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343121.4M79](/packages/google-cloud-core)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[sylius/promotion

Flexible promotion management for PHP applications.

28477.8k9](/packages/sylius-promotion)[ymsoft/filament-money

Filament plugin for convenient storage and management of monetary fields

103.4k](/packages/ymsoft-filament-money)

PHPackages © 2026

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