<commit_before><?php
namespace Witti\FileConverter\Util;

class Shell {
  const SHELL_SAFE = 1;
  const SHELL_OPTIONS = 2;
  const SHELL_ARG_BASIC = 3;
  const SHELL_ARG_BASIC_DBL = 4;
  const SHELL_ARG_BASIC_DBL_NOEQUAL = 8;
  const SHELL_ARG_BOOL_DBL = 5;
  const SHELL_ARG_BOOL_SGL = 7;
  const SHELL_ARG_BASIC_SGL = 6;

  static public function arg($arg, $mode, $value = NULL) {
    return new Shell($arg, $mode, $value);
  }

  static public function argDouble($arg, $value = TRUE, $mode = NULL) {
    if (isset($mode)) {
      return new Shell($arg, $mode, $value);
    }
    elseif (is_bool($value)) {
      return new Shell($arg, Shell::SHELL_ARG_BOOL_DBL, $value);
    }
    else {
      return new Shell($arg, Shell::SHELL_ARG_BASIC_DBL, $value);
    }
  }

  static public function argOptions($options, $configuration, $group_id = NULL) {
    $relevant = array();
    foreach ($options as $option) {
      if (isset($configuration[$option['name']])) {
        $option['value'] = $configuration[$option['name']];
      }
      elseif (isset($option['default'])) {
        $option['value'] = $option['default'];
      }
      else {
        $option['value'] = NULL;
      }
      if (!isset($group_id) || !isset($option['group'])
        || $group_id === $option['group']) {
        $relevant[] = $option;
      }
    }
    return new Shell($group_id, Shell::SHELL_OPTIONS, $relevant);
  }

  private $argument = NULL;
  private $mode = NULL;
  private $value = NULL;
  public function __construct($arg, $mode, $value = NULL) {
    $this->argument = $arg;
    $this->mode = $mode;
    $this->value = $value;
  }

  public function render() {
    switch ($this->mode) {
      case Shell::SHELL_SAFE:
        return $this->argument;

      case Shell::SHELL_OPTIONS:
        $output = '';
        foreach ($this->value as $opt) {
          $tmp = Shell::arg($opt['name'], $opt['mode'] ? $opt['mode']
            : Shell::SHELL_ARG_BASIC, $opt['value'])->render();
          if ($tmp !== '') {
            $output .= ' ' . $tmp;
          }
        }
        return $output;

      case Shell::SHELL_ARG_BOOL_DBL:
        if ($this->value) {
          return escapeshellarg('--' . $this->argument);
        }
        return '';

      case Shell::SHELL_ARG_BOOL_SGL:
        if ($this->value) {
          return escapeshellarg('-' . $this->argument);
        }
        return '';

      case Shell::SHELL_ARG_BASIC_DBL:
        if (isset($this->value)) {
          return escapeshellarg('--' . $this->argument . '=' . $this->value);
        }

      case Shell::SHELL_ARG_BASIC_DBL_NOEQUAL:
        if (isset($this->value)) {
          return escapeshellarg('--' . $this->argument) . ' ' . escapeshellarg($this->value);
        }

      case Shell::SHELL_ARG_BASIC_SGL:
        if (isset($this->value)) {
          return escapeshellarg('-' . $this->argument) . ' '
            . escapeshellarg($this->value);
        }

      case Shell::SHELL_ARG_BASIC:
      default:
        return escapeshellarg($this->argument);
    }
  }
}<commit_msg>Corrected the switch logic to avoid fall-through.<commit_after><?php
namespace Witti\FileConverter\Util;

class Shell {
  const SHELL_SAFE = 1;
  const SHELL_OPTIONS = 2;
  const SHELL_ARG_BASIC = 3;
  const SHELL_ARG_BASIC_DBL = 4;
  const SHELL_ARG_BASIC_DBL_NOEQUAL = 8;
  const SHELL_ARG_BOOL_DBL = 5;
  const SHELL_ARG_BOOL_SGL = 7;
  const SHELL_ARG_BASIC_SGL = 6;

  static public function arg($arg, $mode, $value = NULL) {
    return new Shell($arg, $mode, $value);
  }

  static public function argDouble($arg, $value = TRUE, $mode = NULL) {
    if (isset($mode)) {
      return new Shell($arg, $mode, $value);
    }
    elseif (is_bool($value)) {
      return new Shell($arg, Shell::SHELL_ARG_BOOL_DBL, $value);
    }
    else {
      return new Shell($arg, Shell::SHELL_ARG_BASIC_DBL, $value);
    }
  }

  static public function argOptions($options, $configuration, $group_id = NULL) {
    $relevant = array();
    foreach ($options as $option) {
      if (isset($configuration[$option['name']])) {
        $option['value'] = $configuration[$option['name']];
      }
      elseif (isset($option['default'])) {
        $option['value'] = $option['default'];
      }
      else {
        $option['value'] = NULL;
      }
      if (!isset($group_id) || !isset($option['group'])
        || $group_id === $option['group']) {
        $relevant[] = $option;
      }
    }
    return new Shell($group_id, Shell::SHELL_OPTIONS, $relevant);
  }

  private $argument = NULL;
  private $mode = NULL;
  private $value = NULL;
  public function __construct($arg, $mode, $value = NULL) {
    $this->argument = $arg;
    $this->mode = $mode;
    $this->value = $value;
  }

  public function render() {
    switch ($this->mode) {
      case Shell::SHELL_SAFE:
        return $this->argument;

      case Shell::SHELL_OPTIONS:
        $output = '';
        foreach ($this->value as $opt) {
          $tmp = Shell::arg($opt['name'], $opt['mode'] ? $opt['mode']
            : Shell::SHELL_ARG_BASIC, $opt['value'])->render();
          if ($tmp !== '') {
            $output .= ' ' . $tmp;
          }
        }
        return $output;

      case Shell::SHELL_ARG_BOOL_DBL:
        if ($this->value) {
          return escapeshellarg('--' . $this->argument);
        }
        return '';

      case Shell::SHELL_ARG_BOOL_SGL:
        if ($this->value) {
          return escapeshellarg('-' . $this->argument);
        }
        return '';

      case Shell::SHELL_ARG_BASIC_DBL:
        if (isset($this->value)) {
          return escapeshellarg('--' . $this->argument . '=' . $this->value);
        }
        return '';

      case Shell::SHELL_ARG_BASIC_DBL_NOEQUAL:
        if (isset($this->value)) {
          return escapeshellarg('--' . $this->argument) . ' ' . escapeshellarg($this->value);
        }
        return '';

      case Shell::SHELL_ARG_BASIC_SGL:
        if (isset($this->value)) {
          return escapeshellarg('-' . $this->argument) . ' '
            . escapeshellarg($this->value);
        }
        return '';

      case Shell::SHELL_ARG_BASIC:
      default:
        return escapeshellarg($this->argument);
    }
  }
}
{'fraction_non_alphanumeric': 0.16400064630796574, 'fraction_numerical': 0.0025852318629827112, 'mean_word_length': 2.436979455857857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '4109224', 'n_tokens_mistral': 2135, 'n_tokens_neox': 2034, 'n_words': 407}