Completed
Pull Request — master (#28)
by Valentyn
02:24
created

ApiTokenRepository::findByToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

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 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Users\Repository;
5
6
use App\Users\Entity\ApiToken;
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Symfony\Bridge\Doctrine\RegistryInterface;
9
10
/**
11
 * @method ApiToken|null find($id, $lockMode = null, $lockVersion = null)
12
 * @method ApiToken|null findOneBy(array $criteria, array $orderBy = null)
13
 * @method ApiToken[]    findAll()
14
 * @method ApiToken[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
15
 */
16
class ApiTokenRepository extends ServiceEntityRepository
17
{
18 19
    public function __construct(RegistryInterface $registry)
19
    {
20 19
        parent::__construct($registry, ApiToken::class);
21 19
    }
22
23 5
    public function findByToken(string $token): ?ApiToken
24
    {
25 5
        return $this->findOneBy([
26 5
            'token' => $token
27
        ]);
28
    }
29
}
30