OneTimeTokensRepository::deleteUnusedFor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace ArgentCrusade\Stronghold;
4
5
use ArgentCrusade\Stronghold\Contracts\OneTimeTokensRepositoryInterface;
6
7
class OneTimeTokensRepository implements OneTimeTokensRepositoryInterface
8
{
9
    /**
10
     * Create new one time token.
11
     *
12
     * @param array $attributes
13
     *
14
     * @return OneTimeToken
15
     */
16
    public function create(array $attributes)
17
    {
18
        return OneTimeToken::create($attributes);
19
    }
20
21
    /**
22
     * Get the first unused token for the given user & optional operation.
23
     *
24
     * @param int|string  $userId
25
     * @param string|null $operation
26
     *
27
     * @return OneTimeToken|null
28
     */
29
    public function firstUnusedFor($userId, string $operation = null)
30
    {
31
        return OneTimeToken::unusedFor($userId, $operation)->first();
32
    }
33
34
    /**
35
     * Invalidate unused tokens for the given user & optional operation.
36
     *
37
     * @param int|string  $userId
38
     * @param string|null $operation
39
     *
40
     * @return mixed
41
     */
42
    public function deleteUnusedFor($userId, string $operation = null)
43
    {
44
        return OneTimeToken::unusedFor($userId, $operation)->delete();
45
    }
46
}
47