From 0f95a8d42ee517b5e093da1200eea205c4ad5ba1 Mon Sep 17 00:00:00 2001 From: Jan Pecha Date: Sat, 9 Sep 2017 19:49:31 +0200 Subject: [PATCH] Assert: added bool() --- readme.md | 1 + src/Assert.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/readme.md b/readme.md index 3e004df..55d24ea 100644 --- a/readme.md +++ b/readme.md @@ -33,6 +33,7 @@ function add($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` diff --git a/src/Assert.php b/src/Assert.php index 42c941f..934d346 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -27,6 +27,20 @@ public static function assert($value, $msg = NULL) } + /** + * Checks if value is bool + * @param mixed + * @param string|NULL + * @return void + * @throws AssertException + * @tracySkipLocation + */ + public static function bool($value, $msg = NULL) + { + self::assert(is_bool($value), self::message($msg, 'int', $value)); + } + + /** * Checks if value is integer * @param mixed