Completed
Push — master ( 7440bd...cf598b )
by Gabriel
03:17
created

UserRepository::findById()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 10
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 */
20 View Code Duplication
    public function findByEmail(string $email)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
    /** @return UserEntity */
32 View Code Duplication
    public function findById(int $id)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    {
34
        $result = $this->createQueryBuilder('u')
35
            ->where('u.id = :id')
36
            ->setParameter('id', $id)
37
            ->getQuery()
38
            ->getResult();
39
40
        return $result && $result[0] ? $result[0] : null;
41
    }
42
}
43