UserRepository::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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