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 / Enum Converter
The EnumConverter converts PHP Enumerations to String.
$converter = new EnumConverter();
// Can only convert to string
$converter->canTransform($myEnum, Type::STRING); // -> bool
$converter->transform($myEnum, Type::STRING); // -> string output
// Force string conversion
$converter = new EnumConverter(true);
$converter->canTransform($myEnum); // -> bool
$converter->transform($myEnum); // -> string output
| Input | Type: String |
|---|---|
$unitEnum::Yes |
"Yes" |
$backedEnum::No |
"No" |
How can I help you explore Laravel packages today?