Passed
Push — master ( 67ed79...f0dac3 )
by Marco Aurélio
03:29
created

LaravelCognitoServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php declare(strict_types=1);
2
3
namespace CustomerGauge\Cognito;
4
5
use Illuminate\Container\Container;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\ServiceProvider;
8
9
final class LaravelCognitoServiceProvider extends ServiceProvider
10
{
11
    public function register()
12
    {
13
        $this->registerIssuer();
14
15
        $this->registerCognitoUserProvider();
16
    }
17
18
    private function registerIssuer(): void
19
    {
20
        $this->app->bind(Issuer::class, function () {
21
            $config = $this->app->get('config');
22
23
            $pool = $config->get('auth.cognito.pool');
24
25
            $region = $config->get('auth.cognito.region');
26
27
            return new Issuer($pool, $region);
28
        });
29
    }
30
31
    private function registerCognitoUserProvider(): void
32
    {
33
        Auth::provider(CognitoUserProvider::class, function (Container $app) {
34
            return $app->make(CognitoUserProvider::class);
35
        });
36
    }
37
}
38