UserRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

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