Completed
Push — SF4 ( 2d2f19...1dd003 )
by Laurent
03:26
created

UserRepository::loadUserByUsername()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
/**
4
 * Entity User.
5
 *
6
 * PHP Version 7
7
 *
8
 * @author    Quétier Laurent <[email protected]>
9
 * @copyright 2018 Dev-Int GLSR
10
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version GIT: $Id$
13
 *
14
 * @link https://github.com/Dev-Int/glsr
15
 */
16
17
namespace App\Repository\Staff;
18
19
use App\Entity\Staff\User;
20
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
21
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
22
use Symfony\Bridge\Doctrine\RegistryInterface;
23
24
/**
25
 * User Repository Entity.
26
 *
27
 * @category Entity
28
 *
29
 * @method User|null find($id, $lockMode = null, $lockVersion = null)
30
 * @method User|null findOneBy(array $criteria, array $orderBy = null)
31
 * @method User[]    findAll()
32
 * @method User[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
33
 */
34
class UserRepository extends ServiceEntityRepository implements UserLoaderInterface
35
{
36
    public function __construct(RegistryInterface $registry)
37
    {
38
        parent::__construct($registry, User::class);
39
    }
40
41
    public function loadUserByUsername($username)
42
    {
43
        return $this->createQueryBuilder('u')
44
            ->where('u.username = :username OR u.email = :email')
45
            ->setParameter('username', $username)
46
            ->setParameter('email', $username)
47
            ->getQuery()
48
            ->getOneOrNullResult();
49
    }
50
51
//    /**
52
//     * @return User[] Returns an array of User objects
53
//     */
54
    /*
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...
55
    public function findByExampleField($value)
56
    {
57
        return $this->createQueryBuilder('u')
58
            ->andWhere('u.exampleField = :val')
59
            ->setParameter('val', $value)
60
            ->orderBy('u.id', 'ASC')
61
            ->setMaxResults(10)
62
            ->getQuery()
63
            ->getResult()
64
        ;
65
    }
66
    */
67
68
    /*
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...
69
    public function findOneBySomeField($value): ?User
70
    {
71
        return $this->createQueryBuilder('u')
72
            ->andWhere('u.exampleField = :val')
73
            ->setParameter('val', $value)
74
            ->getQuery()
75
            ->getOneOrNullResult()
76
        ;
77
    }
78
    */
79
}
80