From 2e47b9c7db158c9dd776c734f8cdb927cf84a4c8 Mon Sep 17 00:00:00 2001 From: Austen Cameron Date: Fri, 9 Oct 2020 15:06:40 -0600 Subject: [PATCH] added isNotEmpty method to HtmlString (#34774) --- src/Illuminate/Support/HtmlString.php | 10 ++++++++++ tests/Support/SupportHtmlStringTest.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Illuminate/Support/HtmlString.php b/src/Illuminate/Support/HtmlString.php index 0232a7bb1c24..fb51312cf3fa 100644 --- a/src/Illuminate/Support/HtmlString.php +++ b/src/Illuminate/Support/HtmlString.php @@ -44,6 +44,16 @@ public function isEmpty() return $this->html === ''; } + /** + * Determine if the given HTML string is not empty. + * + * @return bool + */ + public function isNotEmpty() + { + return $this->html !== ''; + } + /** * Get the HTML string. * diff --git a/tests/Support/SupportHtmlStringTest.php b/tests/Support/SupportHtmlStringTest.php index 6610e6340479..8ed846e17bfb 100644 --- a/tests/Support/SupportHtmlStringTest.php +++ b/tests/Support/SupportHtmlStringTest.php @@ -20,4 +20,14 @@ public function testToString() $html = new HtmlString('

foo

'); $this->assertEquals($str, (string) $html); } + + public function testIsEmpty() + { + $this->assertTrue((new HtmlString(''))->isEmpty()); + } + + public function testIsNotEmpty() + { + $this->assertTrue((new HtmlString('foo'))->isNotEmpty()); + } }