Skip to content

Commit fb64ceb

Browse files
committed
feat: container services
Signed-off-by: Julien Guittard <julien.guittard@me.com>
1 parent 781b68c commit fb64ceb

File tree

7 files changed

+547
-2
lines changed

7 files changed

+547
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"malukenho/docheader": "^1.1",
2222
"phpunit/phpunit": "^11.5",
2323
"squizlabs/php_codesniffer": "^3.12",
24-
"vimeo/psalm": "^6.10"
24+
"vimeo/psalm": "^6.10",
25+
"laminas/laminas-servicemanager": "^3.1"
2526
},
2627
"autoload": {
2728
"psr-4": {

composer.lock

Lines changed: 100 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ConfigProvider.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/**
4+
* This file is part of phayne-io/php-dynamodb and is proprietary and confidential.
5+
* Unauthorized copying of this file, via any medium is strictly prohibited.
6+
*
7+
* @see https://github.com/phayne-io/php-dynamodb for the canonical source repository
8+
* @copyright Copyright (c) 2024-2025 Phayne Limited. (https://phayne.io)
9+
*/
10+
11+
declare(strict_types=1);
12+
13+
namespace Phayne\DynamoDB;
14+
15+
use Aws\DynamoDb\DynamoDbClient;
16+
use Aws\DynamoDb\Marshaler;
17+
use Laminas\ServiceManager\Factory\InvokableFactory;
18+
use Phayne\DynamoDB\Operation\OperationFactory;
19+
use Phayne\DynamoDB\Service\DynamoDbAdapter;
20+
use Phayne\DynamoDB\Service\DynamoDbAdapterInterface;
21+
22+
/**
23+
* Class ConfigProvider
24+
*
25+
* @package Phayne\DynamoDB
26+
*/
27+
class ConfigProvider
28+
{
29+
public function __invoke(): array
30+
{
31+
return [
32+
'dependencies' => $this->getDependencies()
33+
];
34+
}
35+
36+
private function getDependencies(): array
37+
{
38+
return [
39+
'factories' => [
40+
DynamoDbClient::class => Container\DynamoDbClientFactory::class,
41+
DynamoDbAdapter::class => Container\Service\DynamoDbAdapterFactory::class,
42+
Marshaler::class => InvokableFactory::class,
43+
OperationFactory::class => Container\Operation\OperationFactoryFactory::class,
44+
],
45+
'abstract_factories' => [
46+
Container\DynamoDbClientAbstractFactory::class,
47+
],
48+
'aliases' => [
49+
DynamoDbAdapterInterface::class => DynamoDbAdapter::class,
50+
],
51+
];
52+
}
53+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* This file is part of phayne-io/php-dynamodb and is proprietary and confidential.
5+
* Unauthorized copying of this file, via any medium is strictly prohibited.
6+
*
7+
* @see https://github.com/phayne-io/php-dynamodb for the canonical source repository
8+
* @copyright Copyright (c) 2024-2025 Phayne Limited. (https://phayne.io)
9+
*/
10+
11+
declare(strict_types=1);
12+
13+
namespace Phayne\DynamoDB\Container\Operation;
14+
15+
use Aws\DynamoDb\DynamoDbClient;
16+
use Aws\DynamoDb\Marshaler;
17+
use Phayne\DynamoDB\Operation\OperationFactory;
18+
use Psr\Container\ContainerInterface;
19+
20+
/**
21+
* Class OperationFactoryFactory
22+
*
23+
* @package Phayne\DynamoDB\Container\Operation
24+
*/
25+
final class OperationFactoryFactory
26+
{
27+
public function __invoke(ContainerInterface $container): OperationFactory
28+
{
29+
return new OperationFactory(
30+
$container->get(DynamoDbClient::class),
31+
$container->get(Marshaler::class)
32+
);
33+
}
34+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/**
4+
* This file is part of phayne-io/php-dynamodb and is proprietary and confidential.
5+
* Unauthorized copying of this file, via any medium is strictly prohibited.
6+
*
7+
* @see https://github.com/phayne-io/php-dynamodb for the canonical source repository
8+
* @copyright Copyright (c) 2024-2025 Phayne Limited. (https://phayne.io)
9+
*/
10+
11+
declare(strict_types=1);
12+
13+
namespace Phayne\DynamoDB\Container\Service;
14+
15+
use Phayne\DynamoDB\Operation\OperationFactory;
16+
use Phayne\DynamoDB\Service\DynamoDbAdapter;
17+
use Psr\Container\ContainerInterface;
18+
19+
/**
20+
* Class DynamoDbAdapterFactory
21+
*
22+
* @package Phayne\DynamoDB\Container\Service
23+
*/
24+
final class DynamoDbAdapterFactory
25+
{
26+
public function __invoke(ContainerInterface $container): DynamoDbAdapter
27+
{
28+
return new DynamoDbAdapter(
29+
$container->get(OperationFactory::class),
30+
);
31+
}
32+
}

0 commit comments

Comments
 (0)