Completed
Push — master ( 5a9157...819b72 )
by Valentyn
02:56
created

UserRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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