Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
HashedPassword
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
6 / 6
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 fromHash
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getValue
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 equals
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 jsonSerialize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10namespace AppDemo\User\Domain;
11
12use Override;
13use Phexium\Domain\ValueObjectInterface;
14
15final readonly class HashedPassword implements ValueObjectInterface
16{
17    private function __construct(
18        private string $hash,
19    ) {}
20
21    #[Override]
22    public function __toString(): string
23    {
24        return $this->hash;
25    }
26
27    public static function fromHash(string $hash): self
28    {
29        return new self($hash);
30    }
31
32    public function getValue(): string
33    {
34        return $this->hash;
35    }
36
37    #[Override]
38    public function equals(ValueObjectInterface $other): bool
39    {
40        if (!$other instanceof self) {
41            return false;
42        }
43
44        return $this->hash === $other->hash;
45    }
46
47    #[Override]
48    public function jsonSerialize(): string
49    {
50        return $this->hash;
51    }
52}