Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
83.33% covered (warning)
83.33%
5 / 6
66.67% covered (warning)
66.67%
2 / 3
66.67% covered (warning)
66.67%
2 / 3
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
SymfonyPasswordHasher
83.33% covered (warning)
83.33%
5 / 6
66.67% covered (warning)
66.67%
2 / 3
66.67% covered (warning)
66.67%
2 / 3
66.67% covered (warning)
66.67%
2 / 3
3.33
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hash
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isValid
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Auth\Infrastructure\Service;
4
5use App\Auth\Domain\Port\Driven\PasswordHasher;
6use App\Auth\Infrastructure\Security\User\DummyAuthenticatedUser;
7use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
8use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
9
10#[Autoconfigure]
11readonly class SymfonyPasswordHasher implements PasswordHasher
12{
13    public function __construct(private UserPasswordHasherInterface $passwordHasher)
14    {}
15
16    public function hash(string $plainPassword): string
17    {
18        return $this->passwordHasher->hashPassword(
19            new DummyAuthenticatedUser($plainPassword),
20            $plainPassword
21        );
22    }
23
24    public function isValid(string $plainPassword, string $hashedPassword): bool
25    {
26        return $this->passwordHasher->isPasswordValid(new DummyAuthenticatedUser($hashedPassword), $plainPassword);
27    }
28}