A library that normalizes some mixed variable to simple types: int, string, array, bool, null
composer require ap-lib/normalizer
- Allowed custom normalizers
- PHP 8.3 or higher
$normalizer = new BaseNormalizer([
new ThrowableNormalizer(include_trace: false)
]);
$normalizedObject = $normalizer->normalize([
"message" => "some error message",
"exception" => new Exception("file not found", 1543),
]);
$normalizedArray = $normalizedObject->value;
var_export($normalizedArray);
/*
[
'message' => 'some error message',
'exception' =>
[
'type' => 'Exception',
'message' => 'file not found',
'file' => '/code/path/to/file.php',
'line' => 19,
'code' => 1543,
],
]
*/