Coduo\TuTu\ServiceContainer::getParameter PHP Метод

getParameter() публичный Метод

public getParameter ( $id ) : mixed
$id
Результат mixed
    public function getParameter($id)
    {
        if (!array_key_exists($id, $this->parameters)) {
            throw new \RuntimeException(sprintf("Service container does not have parameter with id \"%s\"", $id));
        }
        return $this->parameters[$id];
    }

Usage Example

Пример #1
0
 /**
  * If value is valid string between "%" characters then it might be a parameter
  * so we need to try take it from container.
  *
  * @param $value
  * @return mixed
  */
 private function getValue($value)
 {
     if (!is_string($value)) {
         return $value;
     }
     if ($value[0] != '%' || $value[strlen($value) - 1] != '%') {
         return $value;
     }
     $parameter = trim($value, '%');
     if ($this->container->hasParameter($parameter)) {
         return $this->container->getParameter($parameter);
     }
     return $value;
 }