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

UserRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 3
c 2
b 0
f 2
lcom 0
cbo 3
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A findByEmail() 0 10 3
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