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

UserRepository   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 76.92 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 3
Metric Value
wmc 6
c 3
b 0
f 3
lcom 0
cbo 3
dl 20
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findByEmail() 10 10 3
A findById() 10 10 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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