Telegram\Bot\Api::hasContainer PHP Method

hasContainer() public method

Check if IoC Container has been set.
public hasContainer ( ) : boolean
return boolean
    public function hasContainer()
    {
        return self::$container !== null;
    }

Usage Example

 /**
  * Add a command to the commands list.
  *
  * @param CommandInterface|string $command Either an object or full path to the command class.
  *
  * @return CommandBus
  *
  * @throws TelegramSDKException
  */
 public function addCommand($command)
 {
     if (!is_object($command)) {
         if (!class_exists($command)) {
             throw new TelegramSDKException(sprintf('Command class "%s" not found! Please make sure the class exists.', $command));
         }
         if ($this->telegram->hasContainer()) {
             $command = $this->buildDependencyInjectedCommand($command);
         } else {
             $command = new $command();
         }
     }
     if ($command instanceof CommandInterface) {
         /**
          * At this stage we definitely have a proper command to use.
          * @var Command $command
          */
         $this->commands[$command->getName()] = $command;
         return $this;
     }
     throw new TelegramSDKException(sprintf('Command class "%s" should be an instance of "Telegram\\Bot\\Commands\\CommandInterface"', get_class($command)));
 }