<commit_before><?php

/**
 * PHPOAIPMH Library
 *
 * @license http://opensource.org/licenses/MIT
 * @link https://github.com/caseyamcl/phpoaipmh
 * @version 2.0
 * @package caseyamcl/phpoaipmh
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * ------------------------------------------------------------------
 */

namespace Phpoaipmh\Example;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\Table;
use Phpoaipmh\Example\Example;

class ExampleCommand extends Command {

    private $example;

    public function __construct(Example $example) {
      $this->example = $example;
      parent::__construct();
    }

    protected function configure() {
        $this->setName("phpoaipmh:example")
            ->setDescription("Example implementation of the OAI-PMH library.");
    }

    protected function execute(InputInterface $input, OutputInterface $output) {
        $formatter = $this->getHelper('formatter');

        $data = $this->example->getBasicInformation();
        $output->writeln("Basic information: ");
        foreach ($data as $key => $value) {
          $line = $formatter->formatSection($key, $value);
          $output->writeln($line);
        }

        $data = $this->example->getAvailableMetadataFormats();
        $table = new Table($output);
        $output->writeln("Metadata formats: ");

        $table->setHeaders($data['header']);
        $table->setRows($data['rows']);
        $table->render();

        $data = $this->example->getRecords();
        $table = new Table($output);
        $output->writeln("Ten records: ");

        $table->setHeaders($data['header']);
        $table->setRows($data['rows']);
        $table->render();

        $data = $this->example->tryAnException();
    }
}<commit_msg>changed: added options to the command to call each function separately.<commit_after><?php

/**
 * PHPOAIPMH Library
 *
 * @license http://opensource.org/licenses/MIT
 * @link https://github.com/caseyamcl/phpoaipmh
 * @version 2.0
 * @package caseyamcl/phpoaipmh
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * ------------------------------------------------------------------
 */

namespace Phpoaipmh\Example;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\Table;
use Phpoaipmh\Example\Example;

class ExampleCommand extends Command {

    private $example;

    public function __construct(Example $example) {
      $this->example = $example;
      parent::__construct();
    }

    protected function configure() {
        $this->setName("phpoaipmh:example")
            ->addOption('call', null, InputOption::VALUE_OPTIONAL, '', 'all')
            ->setDescription("Example implementation of the OAI-PMH library.");
    }

    protected function execute(InputInterface $input, OutputInterface $output) {
        $formatter = $this->getHelper('formatter');
        $call = $input->getOption('call');

        if ($call == 'basic' || $call == 'all') {
            $data = $this->example->getBasicInformation();
            $output->writeln("Basic information: ");
            foreach ($data as $key => $value) {
              $line = $formatter->formatSection($key, $value);
              $output->writeln($line);
            }
        }

        if ($call == 'formats' || $call == 'all') {
            $data = $this->example->getAvailableMetadataFormats();
            $table = new Table($output);
            $output->writeln("Metadata formats: ");

            $table->setHeaders($data['header']);
            $table->setRows($data['rows']);
            $table->render();
        }

        if ($call == 'records' || $call == 'all') {
            $data = $this->example->getRecords();
            $table = new Table($output);
            $output->writeln("Ten records: ");

            $table->setHeaders($data['header']);
            $table->setRows($data['rows']);
            $table->render();
        }

        if ($call == 'exception' || $call == 'all') {
            $data = $this->example->tryAnException();
        }
    }
}
{'fraction_non_alphanumeric': 0.18108695652173912, 'fraction_numerical': 0.0008695652173913044, 'mean_word_length': 2.5777604976671853, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 65, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1355510', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1247, 'n_words': 266}