Scalar adapter handles this
by wrapping a single typed field in a minimal schema.
Basic Usage
Available Types
String
Integer
Float
Boolean
Enum
UseScalar::enum() to select one value from a backed enum:
Factory Method Signatures
All factory methods accept the same optional parameters:| Factory | PHP return type |
|---|---|
Scalar::string(...) | string |
Scalar::integer(...) | int |
Scalar::float(...) | float |
Scalar::boolean(...) | bool |
Scalar::enum(...) | The backed enum instance |
Typed Convenience Methods
When you are already working with aStructuredOutput or PendingStructuredOutput
instance, you can skip get() and call a typed accessor that validates the return type:
getString(), getInt(), getFloat(), getBoolean().
These methods throw an exception if the result is not of the expected type, which
provides an extra safety check beyond what get() offers.