Skip to content

Commit

Permalink
Improved null handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Oct 4, 2022
1 parent 6f2139a commit 4811632
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/SafeHtml.php
Expand Up @@ -70,6 +70,11 @@ public function append(...$html)
*/
public static function escape($input, $arrayGlue = ' ')
{
if($input === null)
{
return new static('');
}

if($input instanceof SafeHtml)
{
return $input;
Expand All @@ -85,6 +90,10 @@ public static function escape($input, $arrayGlue = ' ')
$return = '';
foreach($input as $iv)
{
if($iv === null)
{
continue;
}
$return .= $arrayGlue . static::escape($iv, $arrayGlue)->getContent();
}
return new static(substr($return, strlen($arrayGlue)));
Expand Down

0 comments on commit 4811632

Please sign in to comment.