Passed
Push — master ( 419604...046546 )
by Paweł
03:31
created

UserRepository::getOneByPasswordResetToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\User;
6
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
7
use Symfony\Bridge\Doctrine\RegistryInterface;
8
use App\Model\UserInterface;
9
10
/**
11
 * @method User|null find($id, $lockMode = null, $lockVersion = null)
12
 * @method User|null findOneBy(array $criteria, array $orderBy = null)
13
 * @method User[]    findAll()
14
 * @method User[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
15
 */
16
class UserRepository extends ServiceEntityRepository implements UserRepositoryInterface
17
{
18
    public function __construct(RegistryInterface $registry)
19
    {
20
        parent::__construct($registry, User::class);
21
    }
22
23
    public function getOneByEmail(string $email): ?UserInterface
24
    {
25
        return $this->createQueryBuilder('u')
26
            ->andWhere('u.email = :email')
27
            ->setParameter('email', $email)
28
            ->getQuery()
29
            ->getOneOrNullResult()
30
        ;
31
    }
32
33
    public function getOneByPasswordResetToken(string $token): ?UserInterface
34
    {
35
        return $this->createQueryBuilder('u')
36
            ->andWhere('u.passwordResetToken = :token')
37
            ->setParameter('token', $token)
38
            ->getQuery()
39
            ->getOneOrNullResult()
40
            ;
41
    }
42
}
43