toString(); // WHEN $fromUuid = new CrmHashcode($uuid); $fromString = CrmHashcode::fromString($v4String); // THEN expect($fromUuid->value)->toBe($v4String) ->and((string) $fromUuid)->toBe($v4String) ->and($fromString->value)->toBe($v4String) ->and((string) $fromString)->toBe($v4String); }); it('rejects non-v4 uuids with DomainException', function (): void { // GIVEN $v7 = UuidHelper::v7(); $v1 = UuidHelper::fromString('00000000-0000-1000-8000-000000000000'); // WHEN & THEN expect(static fn (): CrmHashcode => new CrmHashcode($v7)) ->toThrow(\DomainException::class) ->and(static fn (): CrmHashcode => new CrmHashcode($v1)) ->toThrow(\DomainException::class); }); it('throws InvalidUuidException when fromString receives invalid uuid', function (): void { // GIVEN / WHEN / THEN expect(static fn (): CrmHashcode => CrmHashcode::fromString('not-a-uuid')) ->toThrow(InvalidUuidException::class); }); });