Completed
Pull Request — master (#212)
by Alexandru
10:59
created

DynamoDbServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
c 0
b 0
f 0
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Rennokki\DynamoDb;
4
5
use Aws\DynamoDb\Marshaler;
6
use Rennokki\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
    public function boot()
17
    {
18
        DynamoDbModel::setDynamoDbClientService(
19
            $this->app->make(DynamoDbClientInterface::class)
0 ignored issues
show
Bug introduced by
The method make() does not exist on Tests\Laravel\App. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
            $this->app->/** @scrutinizer ignore-call */ 
20
                        make(DynamoDbClientInterface::class)

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
20
        );
21
22
        $this->publishes([
0 ignored issues
show
Bug introduced by
The method publishes() does not exist on Rennokki\DynamoDb\DynamoDbServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        $this->/** @scrutinizer ignore-call */ 
23
               publishes([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
            __DIR__.'/../config/dynamodb.php' => app()->basePath('config/dynamodb.php'),
24
        ]);
25
    }
26
27
    /**
28
     * Register the service provider.
29
     */
30
    public function register()
31
    {
32
        $marshalerOptions = [
33
            'nullify_invalid' => true,
34
        ];
35
36
        $this->app->singleton(DynamoDbClientInterface::class, function () use ($marshalerOptions) {
0 ignored issues
show
Bug introduced by
The method singleton() does not exist on Tests\Laravel\App. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        $this->app->/** @scrutinizer ignore-call */ 
37
                    singleton(DynamoDbClientInterface::class, function () use ($marshalerOptions) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
            $client = new DynamoDbClientService(new Marshaler($marshalerOptions), new EmptyAttributeFilter());
38
39
            return $client;
40
        });
41
42
        $this->app->singleton('dynamodb', function () {
43
            return new DynamoDbManager(app(DynamoDbClientInterface::class));
44
        });
45
    }
46
}
47