for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
*
* (c) Yaroslav Honcharuk <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Yarhon\RouteGuardBundle\Controller\ArgumentResolver;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
/**
* Returns the default value defined in the action signature when no value has been given.
* @author Yaroslav Honcharuk <[email protected]>
* @author Iltar van der Berg <[email protected]>
final class DefaultValueResolver implements ArgumentValueResolverInterface
{
* {@inheritdoc}
public function supports(ArgumentResolverContextInterface $context, ArgumentMetadata $argument)
return $argument->hasDefaultValue() || (null !== $argument->getType() && $argument->isNullable() && !$argument->isVariadic());
}
public function resolve(ArgumentResolverContextInterface $context, ArgumentMetadata $argument)
return $argument->hasDefaultValue() ? $argument->getDefaultValue() : null;