Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public function get(string $key): ?string |
||
21 | { |
||
22 | $dispense = Dispense::query()->where('key', $key)->first(); |
||
23 | |||
24 | if (! $dispense instanceof Dispense) { |
||
25 | return null; |
||
26 | } |
||
27 | |||
28 | if ($dispense->getExpiresAt()->greaterThan(Carbon::now())) { |
||
29 | $dispense->delete(); |
||
30 | |||
31 | return null; |
||
32 | } |
||
33 | |||
34 | return $dispense->getToken(); |
||
35 | } |
||
42 |