File tree Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Original file line number Diff line number Diff line change
1
+ /vendor /
2
+ composer.lock
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " technically-php/null-container" ,
3
+ "description" : " Null (always empty) PSR-11 container implementation" ,
4
+ "type" : " library" ,
5
+ "require" : {
6
+ "php" : " >=7.0" ,
7
+ "psr/container" : " ^1.0"
8
+ },
9
+ "license" : " MIT" ,
10
+ "authors" : [
11
+ {
12
+ "name" : " Ivan Voskoboinyk" ,
13
+ "email" : " ivan@voskoboinyk.com"
14
+ }
15
+ ],
16
+ "minimum-stability" : " stable" ,
17
+ "autoload" : {
18
+ "psr-4" : {
19
+ "Technically\\ NullContainer\\ " : " src"
20
+ }
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Technically \NullContainer \Exceptions ;
4
+
5
+ use Psr \Container \NotFoundExceptionInterface ;
6
+ use RuntimeException ;
7
+
8
+ final class ServiceNotFound extends RuntimeException implements NotFoundExceptionInterface
9
+ {
10
+ /**
11
+ * @var string
12
+ */
13
+ private $ serviceName ;
14
+
15
+ /**
16
+ * @param string $serviceName
17
+ */
18
+ public function __construct (string $ serviceName )
19
+ {
20
+ $ this ->serviceName = $ serviceName ;
21
+
22
+ parent ::__construct ("Could not resolve service (` {$ serviceName }`). " );
23
+ }
24
+
25
+ /**
26
+ * @return string
27
+ */
28
+ public function getServiceName (): string
29
+ {
30
+ return $ this ->serviceName ;
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Technically \NullContainer ;
4
+
5
+ use Psr \Container \ContainerInterface ;
6
+ use Technically \NullContainer \Exceptions \ServiceNotFound ;
7
+
8
+ final class NullContainer implements ContainerInterface
9
+ {
10
+ /**
11
+ * Get an entry of the container by its identifier.
12
+ *
13
+ * Always throws `ServiceNotFound` exception.
14
+ *
15
+ * @param string $id Identifier of the entry to look for.
16
+ * @throws ServiceNotFound Always
17
+ */
18
+ public function get ($ id )
19
+ {
20
+ throw new ServiceNotFound ($ id );
21
+ }
22
+
23
+ /**
24
+ * Check if the container can return an entry for the given identifier
25
+ *
26
+ * Always returns false.
27
+ *
28
+ * @param string $id
29
+ * @return false
30
+ */
31
+ public function has ($ id )
32
+ {
33
+ return false ;
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments