<commit_before><?php

namespace Drubo\Robo\Task\Project\Config;

use Drubo\Robo\Task\BaseTask;
use Robo\Common\BuilderAwareTrait;
use Robo\Contract\BuilderAwareInterface;
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Validator\Constraints\Url;
use Symfony\Component\Yaml\Yaml;

/**
 * Robo task: Initialize project configuration.
 */
class Initialize extends BaseTask implements BuilderAwareInterface {

  use BuilderAwareTrait;

  /**
   * Input object.
   *
   * @var \Symfony\Component\Console\Input\InputInterface
   */
  protected $input;

  /**
   * Output object.
   *
   * @var \Symfony\Component\Console\Output\OutputInterface
   */
  protected $output;

  /**
   * Question helper.
   *
   * @var \Symfony\Component\Console\Helper\SymfonyQuestionHelper
   */
  protected $questionHelper;

  /**
   * Constructor.
   */
  public function __construct() {
    $this->input = $this->getDrubo()
      ->getInput();

    $this->output = $this->getDrubo()
      ->getOutput();

    $this->questionHelper = new SymfonyQuestionHelper();
  }

  /**
   * Interactively ask for environment name.
   *
   * @return string
   *   The environment name.
   */
  protected function environment() {
    $oldEnvironment = $this->projectConfig()->has('environment') ? $this->projectConfig()->get('environment') : NULL;

    $environmentList = $this->getDrubo()
      ->getEnvironmentList()
      ->toArray();

    $question = new ChoiceQuestion('Select environmnent', $environmentList, $oldEnvironment ? array_search($oldEnvironment, $environmentList, TRUE) : NULL);

    $newEnvironment = $this->questionHelper
      ->ask($this->input, $this->output, $question);

    // Environment changed?
    if ($oldEnvironment && $oldEnvironment !== $newEnvironment) {
      $question = new ConfirmationQuestion(sprintf('Are you sure you want to change the environment from <question>%s</question> to <question>%s</question>', $oldEnvironment, $newEnvironment), FALSE);

      $changeEnvironment = $this->questionHelper
        ->ask($this->input, $this->output, $question);

      if (!$changeEnvironment) {
        return $oldEnvironment;
      }
    }

    return $newEnvironment;
  }

  /**
   * {@inheritdoc}
   */
  public function run() {
    $this->printTaskInfo('Initializing Drubo');

    $projectDirectory = $this->getDrubo()
      ->getProjectDirectory();

    $data = [<commit_msg>Fix status message of project config init task<commit_after><?php

namespace Drubo\Robo\Task\Project\Config;

use Drubo\Robo\Task\BaseTask;
use Robo\Common\BuilderAwareTrait;
use Robo\Contract\BuilderAwareInterface;
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Validator\Constraints\Url;
use Symfony\Component\Yaml\Yaml;

/**
 * Robo task: Initialize project configuration.
 */
class Initialize extends BaseTask implements BuilderAwareInterface {

  use BuilderAwareTrait;

  /**
   * Input object.
   *
   * @var \Symfony\Component\Console\Input\InputInterface
   */
  protected $input;

  /**
   * Output object.
   *
   * @var \Symfony\Component\Console\Output\OutputInterface
   */
  protected $output;

  /**
   * Question helper.
   *
   * @var \Symfony\Component\Console\Helper\SymfonyQuestionHelper
   */
  protected $questionHelper;

  /**
   * Constructor.
   */
  public function __construct() {
    $this->input = $this->getDrubo()
      ->getInput();

    $this->output = $this->getDrubo()
      ->getOutput();

    $this->questionHelper = new SymfonyQuestionHelper();
  }

  /**
   * Interactively ask for environment name.
   *
   * @return string
   *   The environment name.
   */
  protected function environment() {
    $oldEnvironment = $this->projectConfig()->has('environment') ? $this->projectConfig()->get('environment') : NULL;

    $environmentList = $this->getDrubo()
      ->getEnvironmentList()
      ->toArray();

    $question = new ChoiceQuestion('Select environmnent', $environmentList, $oldEnvironment ? array_search($oldEnvironment, $environmentList, TRUE) : NULL);

    $newEnvironment = $this->questionHelper
      ->ask($this->input, $this->output, $question);

    // Environment changed?
    if ($oldEnvironment && $oldEnvironment !== $newEnvironment) {
      $question = new ConfirmationQuestion(sprintf('Are you sure you want to change the environment from <question>%s</question> to <question>%s</question>', $oldEnvironment, $newEnvironment), FALSE);

      $changeEnvironment = $this->questionHelper
        ->ask($this->input, $this->output, $question);

      if (!$changeEnvironment) {
        return $oldEnvironment;
      }
    }

    return $newEnvironment;
  }

  /**
   * {@inheritdoc}
   */
  public function run() {
    $this->printTaskInfo('Initializing project configuration');

    $projectDirectory = $this->getDrubo()
      ->getProjectDirectory();

    $data = [
{'fraction_non_alphanumeric': 0.13766583349355893, 'fraction_numerical': 0.0, 'mean_word_length': 3.665470852017937, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 61, 'https://': 0, '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': '4544521', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1489, 'n_words': 300}