DynamoDbServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 1
A register() 0 14 1
1
<?php
2
3
namespace BaoPham\DynamoDb;
4
5
use Aws\DynamoDb\Marshaler;
6
use BaoPham\DynamoDb\DynamoDb\DynamoDbManager;
7
use Illuminate\Support\ServiceProvider;
8
9
class DynamoDbServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application events.
13
     *
14
     * @return void
15
     */
16 145
    public function boot()
17
    {
18 145
        DynamoDbModel::setDynamoDbClientService($this->app->make(DynamoDbClientInterface::class));
19
20 145
        $this->publishes([
21 145
            __DIR__.'/../config/dynamodb.php' => app()->basePath('config/dynamodb.php'),
22
        ]);
23 145
    }
24
25
    /**
26
     * Register the service provider.
27
     */
28 145
    public function register()
29
    {
30
        $marshalerOptions = [
31 145
            'nullify_invalid' => true,
32
        ];
33
34
        $this->app->singleton(DynamoDbClientInterface::class, function () use ($marshalerOptions) {
35 145
            $client = new DynamoDbClientService(new Marshaler($marshalerOptions), new EmptyAttributeFilter());
36
37 145
            return $client;
38 145
        });
39
40
        $this->app->singleton('dynamodb', function () {
41 136
            return new DynamoDbManager(app(DynamoDbClientInterface::class));
42 145
        });
43 145
    }
44
}
45