@@ -53,8 +53,8 @@ Id::fromInt(123);
5353final class Profile
5454{
5555 public function __construct(
56- public readonly PositiveInt $id,
57- public readonly NonEmptyStr $firstName,
56+ public readonly IntegerPositive $id,
57+ public readonly StringNonEmpty $firstName,
5858 public readonly ?FloatNonNegative $height,
5959 ) {}
6060
@@ -64,8 +64,8 @@ final class Profile
6464 string|float|int|null $height,
6565 ): static {
6666 return new static(
67- PositiveInt ::fromInt($id),
68- NonEmptyStr ::fromString($firstName),
67+ IntegerPositive ::fromInt($id),
68+ StringNonEmpty ::fromString($firstName),
6969 $height !== null ? FloatNonNegative::fromString((string) $height) : null,
7070 );
7171 }
@@ -81,7 +81,7 @@ Profile::fromScalars(id: 157, firstName: 'Tom', height: null);
8181// From array
8282$profile = Profile::fromScalars(...[157, 'Tom', null]);
8383// Accessing values
84- $profile->getHeight(); // "172.5 \ Undefined" type class
84+ $profile->getHeight(); // "172.5" OR " Undefined" type class (will throw an exception on trying to get value)
8585```
8686
8787## Key Features
0 commit comments