/** * Instance a model * * @param string $model Model name to instance * @throws \InvalidArgumentException case param $model is not a string * @throws \RuntimeException case model do not exists * @return object */ protected function model($model) { if ($this->modelDispatcher === null) { ControllerException::modelDispatcherNotDefined(); } elseif ($this->modelsNamespace === null) { ControllerException::modelsNamespaceNotDefined(); } return $this->modelDispatcher->dispatch($this->getModelsNamespace(), $model); }