N98\Magento\Application\Config::newCommand PHP Method

newCommand() private method

private newCommand ( string $className, string | null $commandName ) : Command
$className string
$commandName string | null
return Symfony\Component\Console\Command\Command
    private function newCommand($className, $commandName)
    {
        /** @var Command $command */
        if (!(is_string($className) || is_object($className))) {
            throw new InvalidArgumentException(sprintf('Command classname must be string, %s given', gettype($className)));
        }
        if (!class_exists($className)) {
            return null;
        }
        if (false === is_subclass_of($className, self::COMMAND_CLASS, true)) {
            throw new InvalidArgumentException(sprintf('Class "%s" is not a Command (subclass of "%s")', $className, self::COMMAND_CLASS));
        }
        $command = new $className();
        if (null !== $commandName) {
            $command->setName($commandName);
        }
        return $command;
    }