Skip to content

Commit 15f81a1

Browse files
authored
Update functions.php
1 parent 99ee0e1 commit 15f81a1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/functions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
*/
1414
function cget(ContainerInterface $container, string $id, $default = null, bool $invokable = true): mixed
1515
{
16-
if ($container->has($id)) {
16+
try {
1717
return $container->get($id);
18+
} catch (NotFoundExceptionInterface) {
19+
return $invokable && is_callable($default) ? $default($container) : $default ;
1820
}
19-
20-
return $invokable && is_callable($default) ? $default($container) : $default ;
2121
}

0 commit comments

Comments
 (0)