Skip to content

Commit 9fcf35d

Browse files
authored
Update functions.php
1 parent 5e11c3b commit 9fcf35d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/functions.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
* @param string $id
1010
* @param mixed $default
1111
* @param bool $invokable
12+
* @throws NotFoundExceptionInterface No entry was found for **this** identifier.
1213
* @throws ContainerExceptionInterface Error while retrieving the entry.
1314
* @return mixed
1415
*/
1516
function cget(ContainerInterface $container, string $id, $default = null, bool $invokable = true): mixed
1617
{
17-
try {
18+
if ($container->has($id)) {
1819
return $container->get($id);
19-
} catch (NotFoundExceptionInterface) {
20-
return $invokable && is_callable($default) ? $default($container) : $default ;
2120
}
21+
22+
return $invokable && is_callable($default) ? $default($container) : $default ;
2223
}

0 commit comments

Comments
 (0)