Completed
Push — master ( 9078e8...7440bd )
by Gabriel
02:37
created

UserRepository::findByEmail()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 3
eloc 7
nc 4
nop 1
1
<?php
2
3
namespace Sinergi\Users\Doctrine\User;
4
5
use Doctrine\DBAL\LockMode;
6
use Doctrine\ORM\EntityRepository;
7
use Sinergi\Users\User\UserRepositoryInterface;
8
9
/**
10
 * @method UserEntity find($id, $lockMode = LockMode::NONE, $lockVersion = null)
11
 * @method UserEntity findOneBy(array $criteria, array $orderBy = null)
12
 * @method UserEntity findOneById(array $criteria, array $orderBy = null)
13
 * @method UserEntity findOneByEmail(array $criteria, array $orderBy = null)
14
 * @method UserEntity findOneByEmailConfirmationToken(array $criteria, array $orderBy = null)
15
 * @method UserEntity findOneByPasswordResetToken(array $criteria, array $orderBy = null)
16
 */
17
class UserRepository extends EntityRepository implements UserRepositoryInterface
18
{
19
    /** @return UserEntity|null */
20
    public function findByEmail(string $email)
21
    {
22
        $result = $this->createQueryBuilder('u')
23
            ->where('u.email = :email')
24
            ->setParameter('email', $email)
25
            ->getQuery()
26
            ->getResult();
27
28
        return $result && $result[0] ? $result[0] : null;
29
    }
30
}
31