<commit_before><?php

namespace Valentine94\Vmgen;

use DirectoryIterator;
use ErrorException;
use FilesystemIterator;
use InvalidArgumentException;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use ZipArchive;

/**
 * Class Vmgen.
 *
 * @package Vmgen
 */
class Vmgen {
  /**
   * DrupalVM version.
   */
  const DRUPALVM_VERSION = '4.7.0';
  /**
   * Number of steps for progress bar.
   *
   * @var int
   */
  protected static $progressBarSteps = 15;
  /**
   * Arguments array.
   *
   * @var array
   */
  protected $arguments;
  /**
   * Current system's user name.
   *
   * @var string
   */
  protected $currentUser;
  /**
   * Platform name.
   *
   * @var string
   */
  protected $platform;
  /**
   * Projects directory path.
   *
   * @var string
   */
  protected $projectsDirectory;
  /**
   * VMGen directory path.
   *
   * @var string
   */
  protected $vmgenDirectory;

  /**
   * Vmgen constructor.
   *
   * @param string $vmgen_directory
   *   VMGen directory path.
   */
  public function __construct($vmgen_directory) {
    $this->vmgenDirectory = $vmgen_directory;
    $this->progressBar(0);
    $this->currentUser = get_current_user();
    $this->progressBar(1);
    $this->platform = (stripos(PHP_OS, 'darwin') === 0) ? 'Mac' : 'Linux';
    $this->progressBar(2);
    $this->projectsDirectory =
      (
        $this->platform === 'Mac'
          ? '/Users/'
          : '/home/'
      ) . $this->currentUser . '/projects';
    $this->progressBar(3);
  }

  /**
   * Show help message.
   */
  public static function showHelpMessage() {
    echo "Usage: vmgen-php --php=PHP_VERSION --project-name=PROJECT_NAME\n\n";
    echo "Arguments explanation:\n";
    echo "--php \t\t PHP version\n";
    echo "--project-name \t Project name version\n";
    exit;
  }

  /**
   * Prepare required arguments for VM generation.
   *
   * @param array $args
   *   Arguments array.
   *
   * @return $this
   */
  public function prepareArguments($args) {
    // Ignore the first arg as it is a command name.
    unset($args[0]);

    // Parse the cli arguments into a correct array format.
    $this->arguments = [];
    foreach ($args as $argument) {
      // Check for a php version argument.
      if (stripos($argument, '--php') !== FALSE) {
        $this->arguments['php'] = str_replace('--php=', '', $argument);
        if ($this->arguments['php'] == '5') {
          $this->arguments['php'] = "'5.6'";
        }
        elseif ($this->arguments['php'] == '7') {
          $this->arguments['php'] = "'7.0'";
        }
        continue;
      }
      // Check for a project name argument.
      if (stripos($argument, '--project-name') !== FALSE) {
        $this->arguments['project_name'] = str_replace('--project-name=', '', $argument);
        continue;
      }
    }
    $this->progressBar(4);<commit_msg>Update Vmgen.php<commit_after><?php

namespace Valentine94\Vmgen;

use DirectoryIterator;
use ErrorException;
use FilesystemIterator;
use InvalidArgumentException;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use ZipArchive;

/**
 * Class Vmgen.
 *
 * @package Vmgen
 */
class Vmgen {
  /**
   * DrupalVM version.
   */
  const DRUPALVM_VERSION = '4.7.0';
  /**
   * Number of steps for progress bar.
   *
   * @var int
   */
  protected static $progressBarSteps = 15;
  /**
   * Arguments array.
   *
   * @var array
   */
  protected $arguments;
  /**
   * Current system's user name.
   *
   * @var string
   */
  protected $currentUser;
  /**
   * Platform name.
   *
   * @var string
   */
  protected $platform;
  /**
   * Projects directory path.
   *
   * @var string
   */
  protected $projectsDirectory;
  /**
   * VMGen directory path.
   *
   * @var string
   */
  protected $vmgenDirectory;

  /**
   * Vmgen constructor.
   *
   * @param string $vmgen_directory
   *   VMGen directory path.
   */
  public function __construct($vmgen_directory) {
    $this->vmgenDirectory = $vmgen_directory;
    $this->progressBar(0);
    $this->currentUser = get_current_user();
    $this->progressBar(1);
    $this->platform = (stripos(PHP_OS, 'darwin') === 0) ? 'Mac' : 'Linux';
    $this->progressBar(2);
    $this->projectsDirectory =
      (
        $this->platform === 'Mac'
          ? '/Users/'
          : '/home/'
      ) . $this->currentUser . '/projects';
    $this->progressBar(3);
  }

  /**
   * Show help message.
   */
  public static function showHelpMessage() {
    echo "Usage: vmgen-php --php=PHP_VERSION --project-name=PROJECT_NAME\n\n";
    echo "Arguments explanation:\n";
    echo "--php \t\t PHP version\n";
    echo "--project-name \t Project name version\n";
    exit;
  }

  /**
   * Prepare required arguments for VM generation.
   *
   * @param array $args
   *   Arguments array.
   *
   * @return $this
   */
  public function prepareArguments(array $args) {
    // Ignore the first arg as it is a command name.
    unset($args[0]);

    // Parse the cli arguments into a correct array format.
    $this->arguments = [];
    foreach ($args as $argument) {
      // Check for a php version argument.
      if (stripos($argument, '--php') !== FALSE) {
        $this->arguments['php'] = str_replace('--php=', '', $argument);
        if ($this->arguments['php'] == '5') {
          $this->arguments['php'] = "'5.6'";
        }
        elseif ($this->arguments['php'] == '7') {
          $this->arguments['php'] = "'7.0'";
        }
        continue;
      }
      // Check for a project name argument.
      if (stripos($argument, '--project-name') !== FALSE) {
        $this->arguments['project_name'] = str_replace('--project-name=', '', $argument);
        continue;
      }
    }
    $this->progressBar(4);
{'fraction_non_alphanumeric': 0.1614373356704645, 'fraction_numerical': 0.007011393514460999, 'mean_word_length': 2.388361045130641, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '1819769', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1829, 'n_words': 427}