Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f759b58

Browse files
committed
up: add a new assert helper method Assert::empty
1 parent 20b2fa3 commit f759b58

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎src/Helper/Assert.php‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ public static function notEmpty(mixed $value, string $errMsg = '', bool $isPrefi
4646
}
4747
}
4848

49+
/**
50+
* Assert value is empty, otherwise will throw ex.
51+
*
52+
* @param mixed $value
53+
* @param string $errMsg
54+
* @param bool $isPrefix
55+
*/
56+
public static function empty(mixed $value, string $errMsg = '', bool $isPrefix = false): void
57+
{
58+
if (!empty($value)) {
59+
if ($errMsg) {
60+
$errMsg = $isPrefix ? "$errMsg should be empty" : $errMsg;
61+
} else {
62+
$errMsg = 'Expected a empty value';
63+
}
64+
65+
throw static::createEx($errMsg);
66+
}
67+
}
68+
4969
/**
5070
* @param mixed $value
5171
* @param string $errMsg

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /