-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfigProvider.php
54 lines (44 loc) · 1.6 KB
/
ConfigProvider.php
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
namespace AMC\Broker;
use AMC\Broker\RequestHandler\PostOrPut\PostOrPutHandler;
use AMC\Broker\RequestHandler\PostOrPut\SpecificMethodHandler\Post;
use AMC\Broker\RequestHandler\PostOrPut\SpecificMethodHandler\Put;
use PDO;
use function DI\autowire;
use function DI\factory;
use function DI\get;
class ConfigProvider
{
public function __invoke(): array
{
return [
'container_definitions' => $this->getContainerDefinitions(),
self::class => [
Factory\PDOFactory::class => $this->getPDOConfig(),
]
];
}
public function getContainerDefinitions(): array
{
return [
PDO::class => factory(Factory\PDOFactory::class),
Persistence\PersistenceInterface::class => autowire(Persistence\Postgres::class),
Persistence\IDGeneratorInterface::class => autowire(Persistence\IDGenerator::class),
RequestHandler\PostOrPut\PostOrPutHandler::class => autowire(PostOrPutHandler::class)
->constructorParameter('postHandler', get(Post::class))
->constructorParameter('putHandler', get(Put::class)),
];
}
public function getPDOConfig(): array
{
return [
Factory\PDOFactory::DRIVE_NAME => 'pgsql',
Factory\PDOFactory::HOSTNAME => '127.0.0.1',
Factory\PDOFactory::PORT => 5432,
Factory\PDOFactory::USERNAME => 'postgres',
Factory\PDOFactory::PASSWORD => 'root',
Factory\PDOFactory::HOW_MANY_CONNECTION_TRIES_BEFORE_FAIL => 0,
];
}
}