Completed
Push — master ( 5b6d3c...e19d53 )
by Marcel
03:17
created

PasswordResetTokenRepository::findOneByToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\PasswordResetToken;
6
use App\Entity\User;
7
use Doctrine\ORM\EntityManagerInterface;
8
9
class PasswordResetTokenRepository implements PasswordResetTokenRepositoryInterface {
10
11
    private $em;
12
13 1
    public function __construct(EntityManagerInterface $entityManager) {
14 1
        $this->em = $entityManager;
15 1
    }
16
17 1
    public function persist(PasswordResetToken $passwordResetToken) {
18 1
        $this->em->persist($passwordResetToken);
19 1
        $this->em->flush();
20 1
    }
21
22 1
    public function remove(PasswordResetToken $passwordResetToken) {
23 1
        $this->em->remove($passwordResetToken);
24 1
        $this->em->flush();
25 1
    }
26
27 1
    public function findOneByUser(User $user): ?PasswordResetToken {
28 1
        return $this->em->getRepository(PasswordResetToken::class)
29 1
            ->findOneBy([
30 1
                'user' => $user
31
            ]);
32
    }
33
34
    public function findOneByToken(string $token): ?PasswordResetToken {
35
        return $this->em->getRepository(PasswordResetToken::class)
36
            ->findOneBy([
37
                'token' => $token
38
            ]);
39
    }
40
}