Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
83.33% |
5 / 6 |
|
66.67% |
2 / 3 |
|
66.67% |
2 / 3 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SymfonyPasswordHasher | |
83.33% |
5 / 6 |
|
66.67% |
2 / 3 |
|
66.67% |
2 / 3 |
|
66.67% |
2 / 3 |
3.33 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hash | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isValid | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Auth\Infrastructure\Service; |
| 4 | |
| 5 | use App\Auth\Domain\Port\Driven\PasswordHasher; |
| 6 | use App\Auth\Infrastructure\Security\User\DummyAuthenticatedUser; |
| 7 | use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; |
| 8 | use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; |
| 9 | |
| 10 | #[Autoconfigure] |
| 11 | readonly 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 | } |