public function getTargetTypeForSource($source, $originalTargetType, PropertyMappingConfigurationInterface $configuration = null)
{
$targetType = $originalTargetType;
if (is_array($source) && array_key_exists('__type', $source)) {
$targetType = $source['__type'];
if ($configuration === null) {
throw new \InvalidArgumentException('A property mapping configuration must be given, not NULL.', 1421443628);
}
if ($configuration->getConfigurationValue(ObjectConverter::class, self::CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED) !== true) {
throw new InvalidPropertyMappingConfigurationException('Override of target type not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED" to TRUE.', 1421443641);
}
if ($targetType !== $originalTargetType && is_a($targetType, $originalTargetType, true) === false) {
throw new InvalidDataTypeException('The given type "' . $targetType . '" is not a subtype of "' . $originalTargetType . '".', 1421443648);
}
}
return $targetType;
}