public function registerCommands(string $namespace, string $basePath): self
    {
        $length   = \strlen($basePath) + 1;
        $iterator = Helper::directoryIterator($basePath, $this->getFileFilter());

        foreach ($iterator as $file) {
            $class = $namespace . '\\' . \substr($file, $length, -4);
            $this->addCommand($class);
        }

        return $this;
    }
public function registerCommands(string $namespace, string $basePath): self
    {
        $length   = \strlen($basePath) + 1;
        $iterator = Helper::directoryIterator($basePath, $this->getFileFilter());

        foreach ($iterator as $file) {
            $class = $namespace . '\\' . \substr($file, $length, -4);
            $this->addCommand($class);
        }

        return $this;
    }
public function registerCommands ( string $ namespace , string $ basePath ) : self { $ length = \ strlen ( $ basePath ) + 1 ; $ iterator = Helper :: directoryIterator ( $ basePath , $ this -> getFileFilter ( ) ) ; foreach ( $ iterator as $ file ) { $ class = $ namespace . '\\' . \ substr ( $ file , $ length , - 4 ) ; $ this -> addCommand ( $ class ) ; } return $ this ; }
auto register commands from a dir.

```php
$app->registerCommands('SwagPhp\Command', dirname(__DIR__) . '/src/Command');
```

@param string $namespace
@param string $basePath
@return $this
@throws \InvalidArgumentException
auto register commands from a dir .