ApiTokenRepository::findAllByUser()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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 91
    public function __construct(RegistryInterface $registry)
20
    {
21 91
        parent::__construct($registry, ApiToken::class);
22 91
    }
23
24 37
    public function findByToken(string $token): ?ApiToken
25
    {
26 37
        return $this->findOneBy([
27 37
            'token' => $token,
28
        ]);
29
    }
30
31 2
    public function findAllByUser(int $userId): array
32
    {
33 2
        return $this->findBy([
34 2
            'user' => $userId,
35
        ]);
36
    }
37
}
38