czproject / assert
Assert helper.
Fund package maintenance!
Other
Installs: 23 193
Dependents: 9
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/czproject/assert
Requires
- php: 8.0 - 8.4
Requires (Dev)
- nette/tester: ^2.5
README
Assert helper, throws exceptions.
Installation
Download a latest package or use Composer:
composer require czproject/assert
CzProject\Assert requires PHP 8.0 or later.
Usage
use CzProject\Assert\Assert; function add($a, $b) { Assert::int($a); Assert::int($b); return $a + $b; }
assert($value, $msg = NULL)- checks if value isTRUEbool($value, $msg = NULL)- checks if value isboolint($value, $msg = NULL)- checks if value isintintOrNull($value, $msg = NULL)- checks if value isint|NULLfloat($value, $msg = NULL)- checks if value isfloatfloatOrNull($value, $msg = NULL)- checks if value isfloat|NULLnumber($value, $msg = NULL)- checks if value isfloat|intnumberOrNull($value, $msg = NULL)- checks if value isfloat|int|NULLstring($value, $msg = NULL)- checks if value isstringstringOrNull($value, $msg = NULL)- checks if value isstring|NULLtype($value, $type, $msg = NULL)- checks if value is instance of given typetypeOrNull($value, $type, $msg = NULL)- checks if value is instance of given type orNULLnull($value, $msg = NULL)- checks if value isNULLin($value, $arr, $msg = NULL)- checks if value is in arrayinArray($value, $arr, $msg = NULL)- alias forAssert::in()
PhpStan extension
services: - class: CzProject\Assert\Bridges\PhpStan\StaticMethodTypeSpecifyingExtension tags: - phpstan.typeSpecifier.staticMethodTypeSpecifyingExtension
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/