Completed
Push — SF4 ( 4a7883...4059c5 )
by Laurent
07:51
created

UserRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A loadUserByUsername() 0 9 1
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\User;
6
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Symfony\Bridge\Doctrine\RegistryInterface;
9
10
/**
11
 * @method User|null find($id, $lockMode = null, $lockVersion = null)
12
 * @method User|null findOneBy(array $criteria, array $orderBy = null)
13
 * @method User[]    findAll()
14
 * @method User[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
15
 */
16
class UserRepository extends ServiceEntityRepository implements UserLoaderInterface
17
{
18
    public function __construct(RegistryInterface $registry)
19
    {
20
        parent::__construct($registry, User::class);
21
    }
22
23
    public function loadUserByUsername($username)
24
    {
25
        return $this->createQueryBuilder('u')
26
            ->where('u.username = :username OR u.email = :email')
27
            ->setParameter('username', $username)
28
            ->setParameter('email', $username)
29
            ->getQuery()
30
            ->getOneOrNullResult();
31
    }
32
33
//    /**
34
//     * @return User[] Returns an array of User objects
35
//     */
36
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
    public function findByExampleField($value)
38
    {
39
        return $this->createQueryBuilder('u')
40
            ->andWhere('u.exampleField = :val')
41
            ->setParameter('val', $value)
42
            ->orderBy('u.id', 'ASC')
43
            ->setMaxResults(10)
44
            ->getQuery()
45
            ->getResult()
46
        ;
47
    }
48
    */
49
50
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
51
    public function findOneBySomeField($value): ?User
52
    {
53
        return $this->createQueryBuilder('u')
54
            ->andWhere('u.exampleField = :val')
55
            ->setParameter('val', $value)
56
            ->getQuery()
57
            ->getOneOrNullResult()
58
        ;
59
    }
60
    */
61
}
62