Assert helper, throws exceptions.
Download a latest package or use Composer:
composer require czproject/assert
CzProject\Assert requires PHP 5.4.0 or later.
<?php
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|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 orNULLin($value, $arr, $msg = NULL)- checks if value is in array
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/