Skip to content

czproject/assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CzProject\Assert

Build Status

Assert helper, throws exceptions.

Installation

Download a latest package or use Composer:

composer require czproject/assert

CzProject\Assert requires PHP 5.4.0 or later.

Usage

<?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 is TRUE
  • bool($value, $msg = NULL) - checks if value is bool
  • int($value, $msg = NULL) - checks if value is int
  • intOrNull($value, $msg = NULL) - checks if value is int|NULL
  • string($value, $msg = NULL) - checks if value is string
  • stringOrNull($value, $msg = NULL) - checks if value is string|NULL
  • type($value, $type, $msg = NULL) - checks if value is instance of given type
  • typeOrNull($value, $type, $msg = NULL) - checks if value is instance of given type or NULL
  • in($value, $arr, $msg = NULL) - checks if value is in array

License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/

About

Assert helper.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published