phrity/util-transformer
Lightweight PHP utility for transforming values between types. Provides transformers with canTransform()/transform(), plus resolvers to chain and recurse converters. Includes JSON/flatten decoders and converters for basic types, DateTime, enums, Stringable, Throwable and more.
Documentation / Readable Converter
The ReadableConverter converts Boolean and Null to readable String.
$converter = new ReadableConverter();
// Can only convert to string
$converter->canTransform($myBoolOrNull, Type::STRING); // -> bool
$converter->transform($myBoolOrNull, Type::STRING); // -> string output
// Force string conversion
$converter = new ReadableConverter(true);
$converter->canTransform($myBoolOrNull); // -> bool
$converter->transform($myBoolOrNull); // -> string output
| Input | Type: String |
|---|---|
true |
"true" |
false |
"false" |
null |
"null" |
How can I help you explore Laravel packages today?