diff --git a/src/Functions.php b/src/Functions.php index bf2655e..ab24369 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -45,6 +45,7 @@ use Psr\Log\LoggerInterface; use Psr\SimpleCache\CacheInterface; use RuntimeException; +use stdClass; use Stringable; use Throwable; @@ -290,6 +291,20 @@ function info($message, array $context = [], bool $backtrace = false) logs()->info($message, $context); } +/** + * Return a new literal or anonymous object using named arguments. + * + * @return stdClass + */ +function literal(...$arguments) +{ + if (count($arguments) === 1 && array_is_list($arguments)) { + return $arguments[0]; + } + + return (object) $arguments; +} + /** * @param string|Stringable|null $message */