public function getParameterValue(
ParameterAttributeInterface $attribute,
ParameterAttributeResolveContext $context,
): Result {
if (!$attribute instanceof Collection) {
throw new UnexpectedAttributeException(Collection::class, $attribute);
}
if (!$context->isResolved()) {
return Result::fail();
}
$resolvedValue = $context->getResolvedValue();
if (!is_iterable($resolvedValue)) {
return Result::fail();
}
if (is_a($attribute->className, BackedEnum::class, true)) {
$collection = $this->createCollectionOfBackedEnums($resolvedValue, $attribute->className);
} else {
$collection = $this->createCollectionOfObjects(
$resolvedValue,
$context->getHydrator(),
$attribute->className
);
}
return Result::success($collection);
}
Signup or Login in order to comment.