Lines 100.00% 7 / 7
Methods 100.00% 3 / 3
Classes 100.00% 1 / 1
Covered by tests of size
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 toArray 100.00% 5 / 5 100.00% 1 / 1 1
 toJson 100.00% 1 / 1 100.00% 1 / 1 1
14readonly class PwnedPasswordEntity implements Arrayable, Jsonable
15{
16    public function __construct(
17        public string $hashSnippet,
18        public int $count,
19        public bool $matched,
20    ) {}
21
22    /**
23     * @return array<string, mixed>
24     */
25    public function toArray(): array
26    {
27        return [
28            'hash_snippet' => $this->hashSnippet,
29            'count' => $this->count,
30            'matched' => $this->matched,
31        ];
32    }
33
34    public function toJson(): string
35    {
36        return json_encode(get_object_vars($this), flags: JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
37    }
38}