Retrieves the templates to be used by analyzing the options and the configuration.

@param InputInterface $input

@return string[]
160736
protected function getTemplates(InputInterface $input)
    {
        /** @var ConfigurationHelper $configurationHelper */
        $configurationHelper = $this->getHelper('phpdocumentor_configuration');

        $templates = $input->getOption('template');
        if (!$templates) {
            /** @var Template[] $templatesFromConfig */
            $templatesFromConfig = $configurationHelper->getConfigValueFromPath('transformations/templates');
            foreach ($templatesFromConfig as $template) {
                $templates[] = $template->getName();
            }
        }

        if (!$templates) {
            $templates = array('clean');
        }

        return $templates;
    }
1317184
protected function extractFile(InputInterface $input)
    {
        $resource = STDOUT;
        if (null !== $file = $input->getArgument('file')) {
            if (false === $resource = fopen($file, 'w')) {
                return null;
            }
        }

        return $resource;
    }
183691
public function getParameter(InputInterface $input, $key)
    {
        $config = $this->getConfig();
        $adapter = $input->getOption('repo-adapter');

        if ($value = $config->get(['adapters', $adapter, $key])) {
            return $value;
        }

        return $config->get($key);
    }
313862
private function resolveOptions(InputInterface $input)
    {
        $options = [];
        if ($this->supportsCoverage() && $input->getOption('coverage-text')) {
            $options[] = '--coverage-text';
        }
        if ($this->supportsCoverage() && $input->getOption('coverage-clover')) {
            $options[] = sprintf('--coverage-clover %s/coverage.xml', getcwd());
        }
        if (is_file($this->plugin->directory.'/phpunit.xml')) {
            $options[] = sprintf('--configuration %s', $this->plugin->directory);
        } else {
            $options[] = sprintf('--testsuite %s_testsuite', $this->plugin->getComponent());
        }

        return implode(' ', $options);
    }
1189325
private function getResolvedPaths(InputInterface $input)
    {
        $fileName = $input->getOption('file');
        $dirPath = $input->getOption('directory');

        if ($fileName === null && $dirPath === null) {
            throw new RuntimeException('Either the --file or --directory option is required.');
        }

        if ($dirPath !== null) {
            $fileNames = [];
            $finder = new Finder();
            $finder->files()
                ->in($dirPath)
                ->name('/\.(yml|yaml|json)/')
                ->depth('<2')
                ->sortByName()
            ;
            foreach ($finder as $source) {
                $fileNames[] = $source->getFilename();
            }
            if (Path::isRelative($dirPath)) {
                $dirPath = Path::makeAbsolute($dirPath, getcwd());
            }

            return [$fileNames, $dirPath];
        }

        if (Path::isRelative($fileName)) {
            $fileName = Path::makeAbsolute($fileName, getcwd());
        }
        $dirPath = $dirPath ?: dirname($fileName);
        if (Path::isRelative($dirPath)) {
            $dirPath = Path::makeAbsolute($dirPath, getcwd());
        }

        return [(array) basename($fileName), $dirPath];
    }
52924
protected function getAllProjects(InputInterface $input)
    {
        $projects = $this->api()->getProjects();
        if ($input->getOption('sort')) {
            $this->api()->sortResources($projects, $input->getOption('sort'));
        }
        if ($input->getOption('reverse')) {
            $projects = array_reverse($projects, true);
        }

        return $projects;
    }
937215
protected function getOptions(InputInterface $input)
    {
        $options = $this->extras + [
            'queue' => $input->getArgument('queue'),
            'connection' => $input->getArgument('connection'),
            'poll_interval' => (int) $input->getOption('poll-interval'),
        ];

        /** @var ProcessorConfiguratorInterface $processorConfigurator */
        foreach ($this->processorConfigurators as $processorConfigurator) {
            $processorOptions = $processorConfigurator->resolveOptions($input);

            if ($processorConfigurator->isEnabled()) {
                $options += $processorOptions;
            }
        }

        return $options;
    }
1073668
protected function getTemplatesSettings(ContainerInterface $container): array
    {
        $tplConfig = $container->get(SettingsProviderInterface::class)->get(TemplatesSettings::class);

        return $tplConfig;
    }
617433
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $formatter = $this->getHelper('formatter');
        $templates = $this
            ->templateManager
            ->loadTemplates();

        foreach ($templates as $template) {
            $formattedLine = $formatter->formatSection(
                'OK',
                'Template "' . $template['bundle'] . '" installed'
            );

            $output->writeln($formattedLine);
        }
    }
72678
protected function getConfiguration(InputInterface $input): ConsoleConfigInterface
    {
        // If the configuration to use is the default.
        if ($input->getOption('default')) {
            $this->validatePathsExist($input);
            // If it is a directory.
            if ($input->getOption('dir')) {
                return (new DefaultConsoleConfigFactory())
                    ->invokeDir($input->getArgument('source'), $input->getArgument('target'));
            }
            return (new DefaultConsoleConfigFactory())
                ->invokeFile($input->getArgument('source'), $input->getArgument('target'));
        }

        $path = $input->getOption('config');
        // If we have a "=" at the beginning of the option value
        $path = preg_replace('/^\=/', '', $path);

        $factory = $this->getConfigurationFactory($path);

        if ($input->getOption('dir')) {
            $this->validatePathsExist($input);
            return $factory->invokeDir(
                $path,
                $input->getArgument('source'),
                $input->getArgument('target')
            );
        }
        if ($input->getOption('file')) {
            $this->validatePathsExist($input);
            return $factory->invokeFile(
                $path,
                $input->getArgument('source'),
                $input->getArgument('target')
            );
        }
        return $factory->invoke($path);
    }
815130
private function getResolvedPaths(InputInterface $input)
    {
        $fileName = $input->getOption('file');
        $dirPath = $input->getOption('directory');

        if ($fileName === null && $dirPath === null) {
            throw new RuntimeException('Either the --file or --directory option is required.');
        }

        $fileName = $fileName ?: rtrim($dirPath, '/') . '/' . date('YmdHis') . '.yml';
        if (Path::isRelative($fileName)) {
            $fileName = Path::makeAbsolute($fileName, getcwd());
        }

        $dirPath = $dirPath ?: dirname($fileName);
        if (Path::isRelative($dirPath)) {
            $dirPath = Path::makeAbsolute($dirPath, getcwd());
        }

        return [basename($fileName), $dirPath];
    }
171573
private function getDefaultOptions(InputTypeInterface $type)
    {
        return array_merge([
            'force' => false,
            'property' => '',
            'constraints' => null,
            'required' => false,
            'default' => null,
            'modify' => null,
        ], $type->getDefaultOptions());
    }
292587
public function load($input)
    {
        foreach ($this->strategies as $strategy) {
            if ($strategy->supports($input)) {
                return array_map([$this, 'createJsonDefinition'], $strategy->load($input));
            }
        }

        return [];
    }
552191
private function createOptions(InputInterface $input, OutputInterface $output)
    {
        $options = ['notifier' => $this->createNotifier($input, $output)];

        if ($input->hasArgument('path')) {
            $options['path'] = $input->getArgument('path');
        }

        if ($input->hasOption('release')) {
            $options['release'] = $input->getOption('release');
        }

        if ($input->hasOption('tag')) {
            $options['version'] = $input->getOption('tag');
        }

        if ($input->hasOption('exclude')) {
            $options['excludes'] = $input->getOption('exclude');
        }

        if ($input->hasOption('clear')) {
            $options['clear'] = $input->getOption('clear');
        }

        return array_filter($options);
    }
381160
public function initializeInstallerFactory(InputInterface $input)
    {
        $validate   = new Validate();
        $resolver   = new DatabaseResolver();
        $pluginDir  = realpath($validate->directory($input->getOption('plugin')));
        $pluginsDir = $input->getOption('extra-plugins');

        if (!empty($pluginsDir)) {
            $pluginsDir = realpath($validate->directory($pluginsDir));
        }

        $factory             = new InstallerFactory();
        $factory->moodle     = new Moodle($input->getOption('moodle'));
        $factory->plugin     = new MoodlePlugin($pluginDir);
        $factory->execute    = $this->execute;
        $factory->repo       = $validate->gitUrl($input->getOption('repo'));
        $factory->branch     = $validate->gitBranch($input->getOption('branch'));
        $factory->dataDir    = $input->getOption('data');
        $factory->dumper     = $this->initializePluginConfigDumper($input);
        $factory->pluginsDir = $pluginsDir;
        $factory->noInit     = $input->getOption('no-init');
        $factory->database   = $resolver->resolveDatabase(
            $input->getOption('db-type'),
            $input->getOption('db-name'),
            $input->getOption('db-user'),
            $input->getOption('db-pass'),
            $input->getOption('db-host')
        );

        return $factory;
    }
96730
private function getClass(InputInterface $input, string $mpxNamespace): array
    {
        if (!isset($this->namespaceClasses[$mpxNamespace])) {
            $nf = new \NumberFormatter('en', \NumberFormatter::SPELLOUT);
            $className = 'CustomFieldClass'.ucfirst(
                    str_replace('-', '', $nf->format(\count($this->namespaceClasses) + 1))
                );
            $namespace = new PhpNamespace($input->getArgument('namespace'));
            $class = $namespace->addClass($className);
            $this->classNames[$mpxNamespace] = $className;
            $this->namespaceClasses[$mpxNamespace] = $namespace;
            $class->addImplement(CustomFieldInterface::class);

            $class->addComment('@\Lullabot\Mpx\DataService\Annotation\CustomField(');
            $class->addComment('    namespace="'.$mpxNamespace.'",');
            $class->addComment('    service="'.$input->getArgument('data-service').'",');
            $class->addComment('    objectType="'.$input->getArgument('data-object').'",');
            $class->addComment(')');
        } else {
            $namespace = $this->namespaceClasses[$mpxNamespace];
            $class = $namespace->getClasses()[$this->classNames[$mpxNamespace]];
        }

        return [$namespace, $class];
    }
34642
private function getActivities(InputInterface $input, $limit = 0)
    {
        if ($this->hasSelectedEnvironment() && !$input->getOption('all')) {
            return $this->getSelectedEnvironment()
                ->getActivities($limit, $input->getOption('type'));
        }

        return $this->getSelectedProject()
            ->getActivities($limit, $input->getOption('type'));
    }