/** * {@inheritdoc} */ public function get($id, array $args = array(), $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) { $id = $this->getServiceId($id); if (isset($this->services[$id])) { return $this->callService($this->services[$id], $args); } if (self::NULL_ON_INVALID_REFERENCE === $invalidBehavior) { return null; } throw new ServiceNotFoundException($id, alternative($id, $this->services)); }
/** * {@inheritdoc} */ public function get($name) { $name = strtolower($name); if (!array_key_exists($name, $this->parameters)) { if (empty($name)) { throw new ParameterNotFoundException($name); } throw new ParameterNotFoundException($name, alternative($name, $this->parameters)); } return $this->parameters[$name]; }
/** * Add restful route. * * @param array $config * @param string $name */ private function addRestFulRoute(array $config, $name) { $actions = $this->normalizeRestFulAction($config); foreach ($actions as $action) { if (!$this->isRestFulAction($action)) { $alt = alternative($action, array_flip($this->getRestFulAction())); $altStr = count($alt) ? sprintf('Did you mean%s "%s"', count($alt) > 1 ? 's' : '', implode(', ', $alt)) : ''; throw new InvalidArgumentException(sprintf('Unknown restful action "%s" on route named "%s".' . $altStr, $action, $name)); } $restFulName = $name . '_' . $action; $this->addRoute($restFulName, $this->buildRestFulRoute($action, $config)); } }
/** * Get log level. * * @param array $configs * * @return int */ private static function getLevel(array $configs) { if (!isset($configs['level'])) { throw new InvalidArgumentException('There are no log level defined.'); } if (isset(self::$levels[$configs['level']])) { return self::$levels[$configs['level']]; } $alt = alternative($configs['level'], array_keys(self::$levels)); $prefix = ''; if ($alt) { $prefix = sprintf(' Did you mean%s "%s"', count($alt) > 1 ? 's' : '', implode(', ', $alt)); } throw new InvalidArgumentException(sprintf('Unknown log level "%s".', $configs['level'] . $prefix)); }