-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.php
More file actions
38 lines (30 loc) · 1.71 KB
/
Copy pathsample.php
File metadata and controls
38 lines (30 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
declare(strict_types=1);
use function Bag2\Container\autowire;
use function Bag2\Container\get;
use Bag2\Container\Container;
use Bag2\Container\Http\JsonResponseFactory;
use Nyholm\Psr7\Factory\Psr17Factory;
use Psr\Http\Message as HttpMessage;
require __DIR__ . '/vendor/autoload.php';
$container = new Container([
'birthday' => "2112-09-03",
JsonResponseFactory::class => autowire(JsonResponseFactory::class),
HttpMessage\RequestFactoryInterface::class => get(Psr17Factory::class),
HttpMessage\ResponseFactoryInterface::class => get(Psr17Factory::class),
HttpMessage\ServerRequestFactoryInterface::class => get(Psr17Factory::class),
HttpMessage\StreamFactoryInterface::class => get(Psr17Factory::class),
HttpMessage\UploadedFileFactoryInterface::class => get(Psr17Factory::class),
HttpMessage\UriFactoryInterface::class => get(Psr17Factory::class),
Psr17Factory::class => new \Nyholm\Psr7\Factory\Psr17Factory(),
]);
assert($container->get('birthday') === '2112-09-03');
assert($container->get(Psr17Factory::class) instanceof Psr17Factory);
assert($container->get(HttpMessage\RequestFactoryInterface::class) instanceof Psr17Factory);
assert($container->get(HttpMessage\ResponseFactoryInterface::class) instanceof Psr17Factory);
assert($container->get(HttpMessage\ServerRequestFactoryInterface::class) instanceof Psr17Factory);
assert($container->get(HttpMessage\StreamFactoryInterface::class) instanceof Psr17Factory);
assert($container->get(HttpMessage\UploadedFileFactoryInterface::class) instanceof Psr17Factory);
assert($container->get(HttpMessage\UriFactoryInterface::class) instanceof Psr17Factory);
assert($container->get(JsonResponseFactory::class) instanceof JsonResponseFactory);
echo "ok\n";