/**
* Only convert if the given target class has a constructor with one argument being of type given type
*
* @param string $source
* @param string $targetType
* @return bool
*/
public function canConvertFrom($source, $targetType)
{
if (($this->reflectionService->isClassAnnotatedWith($targetType, Flow\Entity::class) || $this->reflectionService->isClassAnnotatedWith($targetType, Flow\ValueObject::class) || $this->reflectionService->isClassAnnotatedWith($targetType, Entity::class)) === true) {
return false;
}
$methodParameters = $this->reflectionService->getMethodParameters($targetType, '__construct');
if (count($methodParameters) !== 1) {
return false;
}
$methodParameter = array_shift($methodParameters);
return $methodParameter['type'] === gettype($source);
}