Completed
Push — master ( f446cd...59ed7d )
by Valentyn
13:46 queued 11:33
created

ApiTokenRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 21
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findByToken() 0 6 1
A findAllByUser() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Users\Repository;
6
7
use App\Users\Entity\ApiToken;
8
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
9
use Symfony\Bridge\Doctrine\RegistryInterface;
10
11
/**
12
 * @method ApiToken|null find($id, $lockMode = null, $lockVersion = null)
13
 * @method ApiToken|null findOneBy(array $criteria, array $orderBy = null)
14
 * @method ApiToken[]    findAll()
15
 * @method ApiToken[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
16
 */
17
class ApiTokenRepository extends ServiceEntityRepository
18
{
19 54
    public function __construct(RegistryInterface $registry)
20
    {
21 54
        parent::__construct($registry, ApiToken::class);
22 54
    }
23
24 22
    public function findByToken(string $token): ?ApiToken
25
    {
26 22
        return $this->findOneBy([
27 22
            'token' => $token,
28
        ]);
29
    }
30
31 1
    public function findAllByUser(int $userId): array
32
    {
33 1
        return $this->findBy([
34 1
            'user' => $userId,
35
        ]);
36
    }
37
}
38