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

ApiTokenRepository::findAllByUser()   A

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 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