SnsServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addSnsCredentials() 0 7 3
A boot() 0 12 1
1
<?php
2
3
namespace NotificationChannels\AwsSns;
4
5
use Aws\Sns\SnsClient as SnsService;
6
use Illuminate\Support\Arr;
7
use Illuminate\Support\ServiceProvider;
8
9
class SnsServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     */
14 2
    public function boot()
15
    {
16 2
        $this->app->when(SnsChannel::class)
17 2
            ->needs(Sns::class)
18
            ->give(function () {
19 2
                return new Sns($this->app->make(SnsService::class));
20 2
            });
21
22
        $this->app->bind(SnsService::class, function () {
23 2
            $config = array_merge(['version' => 'latest'], $this->app['config']['services.sns']);
24
25 2
            return new SnsService($this->addSnsCredentials($config));
26 2
        });
27 2
    }
28
29 2
    protected function addSnsCredentials($config): array
30
    {
31 2
        if (! empty($config['key']) && ! empty($config['secret'])) {
32 2
            $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
33
        }
34
35 2
        return $config;
36
    }
37
}
38