DynamoDbClientFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
c 1
b 0
f 0
dl 0
loc 27
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A factory() 0 6 2
1
<?php
2
3
namespace Guillermoandrae\DynamoDb\Factory;
4
5
use Aws\DynamoDb\DynamoDbClient;
6
7
/**
8
 * DynamoDB client factory.
9
 *
10
 * @author Guillermo A. Fisher <[email protected]>
11
 */
12
final class DynamoDbClientFactory
13
{
14
    /**
15
     * @var array The default client options.
16
     */
17
    private static array $defaultOptions = [
18
        'region' => 'us-west-2',
19
        'version' => 'latest',
20
        'endpoint' => 'http://localhost:8000',
21
        'credentials' => [
22
            'key' => 'not-a-real-key',
23
            'secret' => 'not-a-real-secret',
24
        ]
25
    ];
26
27
    /**
28
     * Returns a DynamoDb client.
29
     *
30
     * @param array|null $options OPTIONAL The client options.
31
     * @return DynamoDbClient The DynamoDb client.
32
     */
33 54
    public static function factory(?array $options = []): DynamoDbClient
34
    {
35 54
        if (empty($options)) {
36 54
            $options = self::$defaultOptions;
37
        }
38 54
        return new DynamoDbClient($options);
39
    }
40
}
41