0 follower

Final Class Yiisoft\Hydrator\Attribute\Parameter\ToString

InheritanceYiisoft\Hydrator\Attribute\Parameter\ToString
ImplementsYiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface, Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeResolverInterface

Converts the resolved value to string. Non-resolved values are skipped.

Method Details

Hide inherited methods

getParameterValue() public method

public getParameterValue( Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface $attribute, Yiisoft\Hydrator\AttributeHandling\ParameterAttributeResolveContext $context ): Yiisoft\Hydrator\Result
$attribute Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface
$context Yiisoft\Hydrator\AttributeHandling\ParameterAttributeResolveContext

                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();
}

            
getResolver() public method

public getResolver( ): self

                public function getResolver(): self
{
    return $this;
}