• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

php-bug-catcher / bug-catcher / 11174163337

04 Oct 2024 04:47AM UTC coverage: 86.701%. Remained the same
11174163337

push

github

tito10047
Fix missing archive it parameter

841 of 970 relevant lines covered (86.7%)

13.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.0
/src/Repository/UserRepository.php
1
<?php
2

3
namespace BugCatcher\Repository;
4

5
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
6
use Doctrine\ORM\QueryBuilder;
7
use Doctrine\Persistence\ManagerRegistry;
8
use BugCatcher\Entity\User;
9
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
10
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
11
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
12

13
/**
14
 * @extends ServiceEntityRepository<User>
15
 *
16
 * @implements PasswordUpgraderInterface<User>
17
 *
18
 * @method User|null find($id, $lockMode = null, $lockVersion = null)
19
 * @method User|null findOneBy(array $criteria, array $orderBy = null)
20
 * @method User[]    findAll()
21
 * @method User[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
22
 */
23
final class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
24
{
25
        public function __construct(ManagerRegistry $registry) {
26
                parent::__construct($registry, User::class);
2✔
27
        }
28

29
        /**
30
         * Used to upgrade (rehash) the user's password automatically over time.
31
         */
32
        public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void {
33
                if (!$user instanceof User) {
×
34
                        throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
×
35
                }
36

37
                $user->setPassword($newHashedPassword);
×
38
                $this->getEntityManager()->persist($user);
×
39
                $this->getEntityManager()->flush();
×
40
        }
41

42
        public function remove(User $entity, bool $flush = false): void {
43
                $this->getEntityManager()->remove($entity);
×
44

45
                if ($flush) {
×
46
                        $this->getEntityManager()->flush();
×
47
                }
48
        }
49

50
        public function createEmpty(string $email, bool $flush): User {
51
                $entity = new User();
×
52
                $entity
×
53
                        ->setEmail($email)
×
54
                        ->setRoles([])
×
55
                        ->setPassword("empty password")
×
56
                        ->setFullname("John Doe");
×
57

58
                $this->save($entity, $flush);
×
59

60
                return $entity;
×
61
        }
62

63
        public function save(User $entity, bool $flush = false): void {
64
                $this->getEntityManager()->persist($entity);
×
65

66
                if ($flush) {
×
67
                        $this->getEntityManager()->flush();
×
68
                }
69
        }
70

71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc