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

Auth::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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