aServices[$sName] = $oService; } /** * Get a previously registered service * * @api * * @param string $sName name of the service to get * @param bool $bMustBeFound if true a DIException is thrown when the service is not found * * @return mixed The service or null when the service is not found and $bMustBeFound is false * @throws \Combodo\iTop\Service\DependencyInjection\DIException */ final public function GetService(string $sName, bool $bMustBeFound = true): mixed { if (!isset($this->aServices[$sName])) { if ($bMustBeFound) { throw new DIException("Service ".json_encode($sName)." not found"); } return null; } return $this->aServices[$sName]; } }