Skip to content

Latest commit

 

History

43 提交

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

仓库 files navigation

CzProject\Assert

Build Status Downloads this Month Latest Stable Version License

Assert helper, throws exceptions.

Donate

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 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
  • float($value, $msg = NULL) - checks if value is float
  • floatOrNull($value, $msg = NULL) - checks if value is float|NULL
  • number($value, $msg = NULL) - checks if value is float|int
  • numberOrNull($value, $msg = NULL) - checks if value is float|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
  • null($value, $msg = NULL) - checks if value is NULL
  • in($value, $arr, $msg = NULL) - checks if value is in array
  • inArray($value, $arr, $msg = NULL) - alias for Assert::in()

PhpStan extension

services:
	-
		class: CzProject\Assert\Bridges\PhpStan\StaticMethodTypeSpecifyingExtension
		tags:
			- phpstan.typeSpecifier.staticMethodTypeSpecifyingExtension

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

关于

Assert helper.

Topics

Resources

Stars

0 stars

关注者

1 watching

复刻s

发布

Sponsor this project

Used by

贡献者

Languages