• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daycry / auth / 23386290410

21 Mar 2026 06:48PM UTC coverage: 64.989% (+1.2%) from 63.76%
23386290410

push

github

web-flow
Merge pull request #43 from daycry/development

v5.0.0

302 of 465 new or added lines in 26 files covered. (64.95%)

19 existing lines in 3 files now uncovered.

3306 of 5087 relevant lines covered (64.99%)

47.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Models/JwtTokenRepository.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Daycry Auth.
7
 *
8
 * (c) Daycry <daycry9@proton.me>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Daycry\Auth\Models;
15

16
use Daycry\Auth\Entities\UserIdentity;
17

18
/**
19
 * Repository for JWT refresh token operations.
20
 *
21
 * Encapsulates JWT refresh token CRUD from UserIdentityModel.
22
 */
23
class JwtTokenRepository
24
{
NEW
25
    public function __construct(
×
26
        private readonly UserIdentityModel $identityModel,
27
    ) {
NEW
28
    }
×
29

30
    /**
31
     * Stores a new JWT refresh token for the given user.
32
     *
33
     * @param int    $userId    User primary key
34
     * @param string $rawToken  The raw (unhashed) token to store
35
     * @param string $expiresAt Datetime string 'Y-m-d H:i:s'
36
     */
NEW
37
    public function createRefreshToken(int $userId, string $rawToken, string $expiresAt): void
×
38
    {
NEW
39
        $this->identityModel->createJwtRefreshToken($userId, $rawToken, $expiresAt);
×
40
    }
41

42
    /**
43
     * Finds a valid (non-expired, non-revoked) JWT refresh token.
44
     *
45
     * @param int    $userId   User primary key
46
     * @param string $rawToken The raw (unhashed) token
47
     */
NEW
48
    public function getRefreshToken(int $userId, string $rawToken): ?UserIdentity
×
49
    {
NEW
50
        return $this->identityModel->getJwtRefreshToken($userId, $rawToken);
×
51
    }
52

53
    /**
54
     * Revokes a JWT refresh token (hard-delete).
55
     *
56
     * @param int $identityId The identity record primary key
57
     */
NEW
58
    public function revokeRefreshToken(int $identityId): void
×
59
    {
NEW
60
        $this->identityModel->delete($identityId);
×
61
    }
62

63
    /**
64
     * Soft-revokes a JWT refresh token by setting revoked_at.
65
     *
66
     * @param int $identityId The identity record primary key
67
     */
NEW
68
    public function softRevokeRefreshToken(int $identityId): void
×
69
    {
NEW
70
        $this->identityModel->revokeIdentityById($identityId);
×
71
    }
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc