Final Class Yiisoft\Hydrator\Attribute\Parameter\ToString
Converts the resolved value to string. Non-resolved values are skipped.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| getParameterValue() | Yiisoft\Hydrator\Attribute\Parameter\ToString | |
| getResolver() | Yiisoft\Hydrator\Attribute\Parameter\ToString |
Method Details
public function getParameterValue(ParameterAttributeInterface $attribute, ParameterAttributeResolveContext $context): Result
{
if (!$attribute instanceof self) {
throw new UnexpectedAttributeException(self::class, $attribute);
}
if ($context->isResolved()) {
$resolvedValue = $context->getResolvedValue();
if (is_scalar($resolvedValue) || null === $resolvedValue || $resolvedValue instanceof Stringable) {
return Result::success((string) $resolvedValue);
}
return Result::success('');
}
return Result::fail();
}
Signup or Login in order to comment.