protected function doDiscovery(array $directories, $base_namespace)
    {
        $forms = [];
        $filter = $this->filterByNamespace($base_namespace);

        foreach ($this->searchFiles($directories, $filter) as $file) {
            $ext = $file->getExtension();
            $classname = $base_namespace . '\\' . $file->getBasename(".$ext");

            if (!class_exists($classname)) {
                throw new \Exception(
                    'Missing class found during form discovery.'
                );
            }
            $instance = new $classname();

            if (!$instance instanceof FormInterface) {
                throw new \Exception(
                    sprintf('Form class (%s) is missing \Droath\ConsoleForm\Form\FormInterface.', $classname)
                );
            }

            $forms[$instance->getName()] = $instance->buildForm();
        }

        return $forms;
    }