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% 3 / 3 100.00% 1 / 1 2
 toArray 100.00% 3 / 3 100.00% 1 / 1 1
 toJson 100.00% 1 / 1 100.00% 1 / 1 1
16readonly class BreachSiteTruncatedEntity implements Arrayable, Jsonable
17{
18    public string $name;
19
20    public function __construct(?stdClass $data = null)
21    {
22        if (null === $data) {
23            throw new RuntimeException('Invalid BreachSite data');
24        }
25
26        $this->name = $data->Name;
27    }
28
29    /**
30     * @return array<string, string>
31     */
32    public function toArray(): array
33    {
34        return [
35            'name' => $this->name,
36        ];
37    }
38
39    public function toJson(): string
40    {
41        return json_encode(get_object_vars($this), flags: JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
42    }
43}