Webmozart\Console\Api\Config\CommandConfig::hasSubCommandConfig PHP Method

hasSubCommandConfig() public method

Returns whether the command has a sub-command with a given name.
See also: beginSubCommand()
public hasSubCommandConfig ( string $name ) : boolean
$name string The name of the sub-command.
return boolean Returns `true` if the sub-command configuration with the given name exists and `false` otherwise.
    public function hasSubCommandConfig($name)
    {
        foreach ($this->subCommandConfigs as $commandConfig) {
            if ($name === $commandConfig->getName()) {
                return true;
            }
        }
        return false;
    }

Usage Example

示例#1
0
 public function testHasSubCommandConfig()
 {
     $this->config->addSubCommandConfig($config = new SubCommandConfig());
     $this->assertFalse($this->config->hasSubCommandConfig('command'));
     $this->assertFalse($this->config->hasSubCommandConfig('foobar'));
     $config->setName('command');
     $this->assertTrue($this->config->hasSubCommandConfig('command'));
     $this->assertFalse($this->config->hasSubCommandConfig('foobar'));
 }