Esempio n. 1
0
 /**
  * Compute string parameter.
  *
  * @param mixed $name
  * @param mixed $value
  *
  * @return string
  */
 private function computeStringParameter($name, $value)
 {
     $name = strtolower($name);
     $resolved = $this->parameter->get($name);
     // Only scalar type can be used in string value.
     if (!is_scalar($resolved)) {
         throw new InvalidArgumentException(sprintf('Parameter "%s" cannot use type %s inside string value "%s".', $name, gettype($resolved), $value));
     }
     return (string) $resolved;
 }
Esempio n. 2
0
 /**
  * Compute parameter value.
  *
  * @param mixed $parameter
  *
  * @return array|mixed|null
  */
 protected function computeParameterValue($parameter)
 {
     $name = $this->getParameterName($parameter);
     if ($this->parameter->has($name)) {
         $value = $this->parameter->get($name);
         return $this->getParameterValue($value);
     }
     if (null !== ($instance = $this->computeParameterClass($parameter))) {
         return $instance;
     }
     return null;
 }
Esempio n. 3
0
 /**
  * Compile parameter.
  *
  * Parameter become immutable.
  *
  * @return static
  */
 public function compile()
 {
     $this->parameter->getResolver()->resolve();
     $this->parameter = new ImmutableParameterBag($this->parameter->all());
     return $this;
 }