if (!
is_subclass_of($type, \BackedEnum::
class)) { throw new InvalidArgumentException('The data must belong to a backed enumeration.'
);
} if ($context[self::ALLOW_INVALID_VALUES
] ?? false
) { if (null ===
$data || (!\
is_int($data) && !\
is_string($data))) { return null;
} try { return $type::
tryFrom($data);
} catch (\TypeError
) { return null;
} } if (!\
is_int($data) && !\
is_string($data)) { throw NotNormalizableValueException::
createForUnexpectedDataType('The data is neither an integer nor a string, you should pass an integer or a string that can be parsed as an enumeration case of type '.
$type.'.',
$data,
[Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_STRING
],
$context['deserialization_path'
] ?? null, true
);
} try { return $type::
from($data);
}