Skip to content

Commit 3b701be

Browse files
authored
Merge pull request #4 from tamellal/container_fix
Making container wrapper return understandable exceptions
2 parents 2c5f3f3 + cb2826a commit 3b701be

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/SanePsr11ContainerAdapter.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
use function class_exists;
8+
use Illuminate\Container\EntryNotFoundException;
89
use Illuminate\Contracts\Container\Container;
910
use Psr\Container\ContainerExceptionInterface;
1011
use Psr\Container\ContainerInterface;
@@ -54,9 +55,14 @@ public function get($id)
5455
*/
5556
public function has($id)
5657
{
57-
if (class_exists($id)) {
58+
if (class_exists($id) && !$this->container->has($id)) {
59+
try {
60+
$this->container->get($id);
61+
} catch (EntryNotFoundException $e) {
62+
return false;
63+
}
5864
return true;
5965
}
6066
return $this->container->has($id);
6167
}
62-
}
68+
}

0 commit comments

Comments
 (0)