{"id":19794133,"url":"https://github.com/simplesamlphp/assert","last_synced_at":"2025-09-02T21:44:24.001Z","repository":{"id":37990919,"uuid":"271495047","full_name":"simplesamlphp/assert","owner":"simplesamlphp","description":"A wrapper around webmozart/assert to make it useful beyond checking method arguments","archived":false,"fork":false,"pushed_at":"2025-01-13T16:41:49.000Z","size":211,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-06T08:01:42.358Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simplesamlphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-11T08:38:46.000Z","updated_at":"2025-01-16T12:27:35.000Z","dependencies_parsed_at":"2023-02-02T18:46:18.485Z","dependency_job_id":"b7744273-3e86-4ec1-b7fe-f730e36c54c4","html_url":"https://github.com/simplesamlphp/assert","commit_stats":{"total_commits":147,"total_committers":3,"mean_commits":49.0,"dds":0.1496598639455783,"last_synced_commit":"c5a33e594455d2b8c40991c6ca8a0b7ef23af395"},"previous_names":[],"tags_count":70,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesamlphp%2Fassert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesamlphp%2Fassert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesamlphp%2Fassert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesamlphp%2Fassert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplesamlphp","download_url":"https://codeload.github.com/simplesamlphp/assert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251812305,"owners_count":21647884,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T07:12:10.966Z","updated_at":"2025-05-01T02:30:55.823Z","avatar_url":"https://github.com/simplesamlphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Assert\n\n![Build Status](https://github.com/simplesamlphp/assert/actions/workflows/php.yml/badge.svg)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/simplesamlphp/assert/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/simplesamlphp/assert/?branch=master)\n[![Coverage Status](https://codecov.io/gh/simplesamlphp/assert/branch/master/graph/badge.svg)](https://codecov.io/gh/simplesamlphp/assert)\n[![PHPStan Enabled](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/simplesamlphp/assert)\n\n## Background\n\nA wrapper around webmozart/assert to make it useful beyond checking method\narguments. One of the major reasons to come up with this fork was our\nrequirement to be able to throw custom exceptions, instead of _everything_\nbeing thrown as a generic `InvalidArgumentException`.\n\nUsing a `__callStatic` wrapper we are able to wrap the webmozart-methods\nallowing for an extra `exception` parameter, and catch the\n`InvalidArgumentException` by the original library, then throw the desired\nexception, or fall back to our custom `AssertionFailedException`.\n\nIn practise, this means that _every_ assertion provided by the original library\ncan be used an provided with an additional parameter. If you provide it, and it\ntranslates into a `Throwable` class, that is what will be thrown as soon as the\nassertion fails. If you don't pass the the extra parameter, we will throw the\nmore generic `AssertionFailedException` (which in our opinion is still better\nthan the even _more_ generic `InvalidArgumentException`).\n\nWe also felt that `InvalidArgumentException` is incorrect to use in this case.\nThis exception was intended by PHP to be thrown when a function parameter is of\nthe wrong type. Our custom `AssertionFailedException` therefore inherits from\n`UnexpectedValueException` which is intended to verify values against valid\nvalue sets, possibly during the internal computations of a function. We deem\nthis much more appropriate for use in assertions.\n\n## Custom Assertions\n\nAnother reason to fork is the ability to add a few custom assertions that may\nonly make sense for XML / SAML2 related things.\n\nCurrently this library provides the following additional assertions:\n\n### Assertions\n\nMethod                                                                       | Description\n-----------------------------------------------------------------------------|-----------------------------------------------------------------\n`stringPlausibleBase64($value, $message = '', ?Throwable $exception = null)` | Check that a value is plausibly base64  \n`validDateTime($value, $message = '', ?Throwable $exception = null)`         | Check that a value is a valid ISO8601 compliant DateTime\n`notInArray($value, $values, $message = '', ?Throwable $exception = null)`   | Check that a value is _NOT_ one of a list of values\n`validURI($value, $message = '', ?Throwable $exception = null)`              | Check that a value is a valid RFC3986 URI\n`validURL($value, $message = '', ?Throwable $exception = null)`              | Check that a value is a valid RFC2396 URL\n`validURN($value, $message = '', ?Throwable $exception = null)`              | Check that a value is a valid RFC8141 URN\n`validNCName($value, $message = '', ?Throwable $exception = null)`           | Check that a value is a valid xs:NCName\n`validQName($value, $message = '', ?Throwable $exception = null)`            | Check that a value is a valid xs:QName\n`validDuration($value, $message = '', ?Throwable $exception = null)`         | Check that a value is a xs:duration\n`validNMTokens($value, $message = '', ?Throwable $exception = null)`         | Check that a value is a xs:NMTokens\n`validNMToken($value, $message = '', ?Throwable $exception = null)`          | Check that a value is a xs:NMToken\n`validHexBinary($value, $message = '', ?Throwable $exception = null)`        | Check that a value is a xs:hexBinary\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplesamlphp%2Fassert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplesamlphp%2Fassert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplesamlphp%2Fassert/lists"}