Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
HashedPassword
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 value
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Identity\Domain\ValueObject;
6
7use InvalidArgumentException;
8
9/**
10 * Wraps an already-hashed password. Hashing itself is an infrastructure concern.
11 */
12final class HashedPassword
13{
14    public function __construct(private readonly string $value)
15    {
16        if ($value === '') {
17            throw new InvalidArgumentException('Hashed password cannot be empty.');
18        }
19    }
20
21    public function __toString(): string
22    {
23        return $this->value;
24    }
25
26    public function value(): string
27    {
28        return $this->value;
29    }
30}