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

UserRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 12
c 1
b 0
f 0
dl 0
loc 24
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getOneByEmail() 0 7 1
A getOneByPasswordResetToken() 0 7 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