UserRepository::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\User;
6
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
7
use Doctrine\Persistence\ManagerRegistry;
8
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
9
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
10
use Symfony\Component\Security\Core\User\UserInterface;
11
12
/**
13
 * @method User|null find($id, $lockMode = null, $lockVersion = null)
14
 * @method User|null findOneBy(array $criteria, array $orderBy = null)
15
 * @method User[]    findAll()
16
 * @method User[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
17
 */
18
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
19
{
20
    public function __construct(ManagerRegistry $registry)
21
    {
22
        parent::__construct($registry, User::class);
23
    }
24
25
    /**
26
     * Used to upgrade (rehash) the user's password automatically over time.
27
     */
28
    public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
29
    {
30
        if (!$user instanceof User) {
31
            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
32
        }
33
34
        $user->setPassword($newEncodedPassword);
35
        $this->_em->persist($user);
36
        $this->_em->flush();
37
    }
38
39
    // /**
40
    //  * @return User[] Returns an array of User objects
41
    //  */
42
    /*
43
    public function findByExampleField($value)
44
    {
45
        return $this->createQueryBuilder('u')
46
            ->andWhere('u.exampleField = :val')
47
            ->setParameter('val', $value)
48
            ->orderBy('u.id', 'ASC')
49
            ->setMaxResults(10)
50
            ->getQuery()
51
            ->getResult()
52
        ;
53
    }
54
    */
55
56
    /*
57
    public function findOneBySomeField($value): ?User
58
    {
59
        return $this->createQueryBuilder('u')
60
            ->andWhere('u.exampleField = :val')
61
            ->setParameter('val', $value)
62
            ->getQuery()
63
            ->getOneOrNullResult()
64
        ;
65
    }
66
    */
67
}
68