Skip to content

Commit

Permalink
added isNotEmpty method to HtmlString (#34774)
Browse files Browse the repository at this point in the history
  • Loading branch information
austenc committed Oct 9, 2020
1 parent 86fc8fb commit 2e47b9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Illuminate/Support/HtmlString.php
Expand Up @@ -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.
*
Expand Down
10 changes: 10 additions & 0 deletions tests/Support/SupportHtmlStringTest.php
Expand Up @@ -20,4 +20,14 @@ public function testToString()
$html = new HtmlString('<h1>foo</h1>');
$this->assertEquals($str, (string) $html);
}

public function testIsEmpty()
{
$this->assertTrue((new HtmlString(''))->isEmpty());
}

public function testIsNotEmpty()
{
$this->assertTrue((new HtmlString('foo'))->isNotEmpty());
}
}

0 comments on commit 2e47b9c

Please sign in to comment.