getKey() public method

public getKey ( ) : string
return string
Esempio n. 1
0
 /**
  * Returns a new instance which will include the passed parameter. If a parameter with that key already exist, it
  * WILL NOT be overridden.
  *
  * @param Parameter $parameter
  *
  * @return self
  */
 public function with(Parameter $parameter) : self
 {
     $key = $parameter->getKey();
     $clone = clone $this;
     if (false === $clone->has($key)) {
         $clone->parameters[$key] = $parameter->getValue();
     }
     return $clone;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  *
  * @param Parameter $parameter
  *
  * @throws ParameterNotFoundException
  */
 public function resolve(Parameter $parameter, ParameterBag $unresolvedParameters, ParameterBag $resolvedParameters, ResolvingContext $context = null) : ParameterBag
 {
     $context = ResolvingContext::createFrom($context, $parameter->getKey());
     $self = $this;
     $value = preg_replace_callback(self::PATTERN, function ($match) use($self, $context, $unresolvedParameters, &$resolvedParameters, $parameter) {
         $key = $match['parameter'];
         $resolvedParameters = $self->resolveStringKey($self->resolver, $parameter, $key, $unresolvedParameters, $resolvedParameters, $context);
         return $resolvedParameters->get($key);
     }, $parameter->getValue());
     return $resolvedParameters->with($parameter->withValue($value));
 }
Esempio n. 3
0
 /**
  * @inheritdoc
  */
 public function resolve(Parameter $unresolvedArrayParameter, ParameterBag $unresolvedParameters, ParameterBag $resolvedParameters, ResolvingContext $context = null) : ParameterBag
 {
     if (null === $this->resolver) {
         throw ResolverNotFoundExceptionFactory::createUnexpectedCall(__METHOD__);
     }
     $context = ResolvingContext::createFrom($context, $unresolvedArrayParameter->getKey());
     $resolvedArray = [];
     /* @var array $unresolvedArray */
     $unresolvedArray = $unresolvedArrayParameter->getValue();
     foreach ($unresolvedArray as $index => $unresolvedValue) {
         // Iterate over all the values of the array to resolve each of them
         $resolvedParameters = $this->resolver->resolve(new Parameter((string) $index, $unresolvedValue), $unresolvedParameters, $resolvedParameters, $context);
         $resolvedArray[$index] = $resolvedParameters->get((string) $index);
         $resolvedParameters = $resolvedParameters->without((string) $index);
     }
     $resolvedParameters = $resolvedParameters->with($unresolvedArrayParameter->withValue($resolvedArray));
     return $resolvedParameters;
 }
 public static function createForWhenResolvingParameter(string $key, Parameter $parameter) : ParameterNotFoundException
 {
     return new ParameterNotFoundException(sprintf('Could not find the parameter "%s" when resolving "%s".', $key, $parameter->getKey()));
 }