Total Complexity | 4 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | final class EmailDispensary |
||
12 | { |
||
13 | const TTL = 1800; |
||
14 | const CHARS = 128; |
||
15 | |||
16 | /** |
||
17 | * @var \App\Auth\Dispensary\Dispensary |
||
18 | */ |
||
19 | private Dispensary $dispensary; |
||
20 | |||
21 | 7 | public function __construct(Dispensary $dispensary) |
|
22 | { |
||
23 | 7 | $this->dispensary = $dispensary; |
|
24 | 7 | } |
|
25 | |||
26 | 4 | public function dispense(Authenticatable $user, string $email): string |
|
27 | { |
||
28 | 4 | return $this->dispensary->dispense($this->getKey($user, $email), self::TTL, self::CHARS); |
|
29 | } |
||
30 | |||
31 | /** |
||
32 | * @param \Illuminate\Contracts\Auth\Authenticatable $user |
||
33 | * @param string $email |
||
34 | * @param string $token |
||
35 | * @return bool |
||
36 | * @throws \App\Auth\Dispensary\Exceptions\TokenExpiredException |
||
37 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
38 | */ |
||
39 | 3 | public function verify(Authenticatable $user, string $email, string $token): bool |
|
40 | { |
||
41 | 3 | return $this->dispensary->verify($this->getKey($user, $email), $token); |
|
42 | } |
||
43 | |||
44 | 4 | private function getKey(Authenticatable $user, string $email): string |
|
51 | ]); |
||
52 | } |
||
53 | } |
||
54 |