DynamoDbClientFactory::factory()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
ccs 4
cts 4
cp 1
cc 2
nc 2
nop 1
crap 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