Skip to content

Commit

Permalink
Added literal helper function (#669)
Browse files Browse the repository at this point in the history
Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
  • Loading branch information
huangdijia and huangdijia authored Jun 11, 2024
1 parent 2173f31 commit ff57934
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use Psr\Log\LoggerInterface;
use Psr\SimpleCache\CacheInterface;
use RuntimeException;
use stdClass;
use Stringable;
use Throwable;

Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit ff57934

Please sign in to comment.