Completed
Push — master ( d51485...4815df )
by yoshihiro
01:33
created

Auth   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 26
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A verifyIdToken() 0 8 2
A getUser() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Piotzkhider\FirebaseAuthenticationModule;
6
7
use Kreait\Firebase\Auth as FirebaseAuth;
8
use Kreait\Firebase\Auth\UserRecord;
9
use Lcobucci\JWT\Token;
10
use Piotzkhider\FirebaseAuthenticationModule\Exception\InvalidToken;
11
12
class Auth implements AuthInterface
13
{
14
    /**
15
     * @var FirebaseAuth
16
     */
17
    private $auth;
18
19 3
    public function __construct(FirebaseAuth $auth)
20
    {
21 3
        $this->auth = $auth;
22 3
    }
23
24 1
    public function verifyIdToken(string $idToken): Token
25
    {
26
        try {
27 1
            return $this->auth->verifyIdToken($idToken);
28
        } catch (\Firebase\Auth\Token\Exception\InvalidToken $e) {
29
            throw new InvalidToken($e->getMessage());
30
        }
31
    }
32
33 1
    public function getUser(string $uid): UserRecord
34
    {
35 1
        return $this->auth->getUser($uid);
36
    }
37
}
38