Last active
January 31, 2024 04:57
-
-
Save rizkytegar/8779a088867912b825f739a48923e990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function e($value, $doubleEncode = true) | |
{ | |
if ($value instanceof DeferringDisplayableValue) { | |
$value = $value->resolveDisplayableValue(); | |
} | |
if ($value instanceof Htmlable) { | |
return $value->toHtml(); | |
} | |
if ($value instanceof BackedEnum) { | |
$value = $value->value; | |
} | |
return htmlspecialchars($value ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', $doubleEncode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment