czproject / assert
Assert helper.
Fund package maintenance!
Other
Installs: 17 861
Dependents: 9
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6.0
Requires (Dev)
- nette/tester: ^2.0
README
Assert helper, throws exceptions.
Installation
Download a latest package or use Composer:
composer require czproject/assert
CzProject\Assert
requires PHP 5.6.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 isTRUE
bool($value, $msg = NULL)
- checks if value isbool
int($value, $msg = NULL)
- checks if value isint
intOrNull($value, $msg = NULL)
- checks if value isint|NULL
float($value, $msg = NULL)
- checks if value isfloat
floatOrNull($value, $msg = NULL)
- checks if value isfloat|NULL
number($value, $msg = NULL)
- checks if value isfloat|int
numberOrNull($value, $msg = NULL)
- checks if value isfloat|int|NULL
string($value, $msg = NULL)
- checks if value isstring
stringOrNull($value, $msg = NULL)
- checks if value isstring|NULL
type($value, $type, $msg = NULL)
- checks if value is instance of given typetypeOrNull($value, $type, $msg = NULL)
- checks if value is instance of given type orNULL
null($value, $msg = NULL)
- checks if value isNULL
in($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/