<commit_before><?php

namespace Zizaco\FactoryMuff;

abstract class Kind
{

  protected $kind = null;
  protected $model = null;

  public function __construct($kind, $model)
  {
    $this->kind = $kind;
    $this->model = $model;
  }

  public static function detect($kind, $model = null)
  {
    if($kind instanceof \Closure) {
      return new Kind\Closure($kind, $model);
    }
    elseif (is_string($kind)) {
      if (substr($kind, 0, 8) == 'factory|')
      {
        return new Kind\Factory($kind, $model);
      }
      elseif (substr($kind, 0, 5) === 'call|' || substr($kind, 0, 4) === 'call')
      {
        return new Kind\Call($kind, $model);
      }
      elseif (substr($kind, 0, 5) === 'date|' || substr($kind, 0, 4) === 'date')
      {
        return new Kind\Date($kind, $model);
      }
      elseif (substr($kind, 0, 8) === 'integer|' || substr($kind, 0, 7) === 'integer')
      {
        return new Kind\Integer($kind, $model);
      }
      elseif (substr($kind, 0, 6) === 'email|' || substr($kind, 0, 5) === 'email')
      {
        return new Kind\Email($kind, $model);
      }
      elseif (substr($kind, 0, 5) === 'text|' || substr($kind, 0, 4) === 'text')
      {
        return new Kind\Text($kind, $model);
      }
      elseif (substr($kind, 0, 7) === 'string|' || substr($kind, 0, 6) === 'string')
      {
        return new Kind\String($kind, $model);
      }
      else
      {
        return new Kind\None($kind, $model);
      }
    }
  }

  public function getOption($index, $default = null)
  {
    $options = $this->getOptions();
    if (isset($options[$index])) {
      return $options[$index];<commit_msg>Remove lots of if statements<commit_after><?php

namespace Zizaco\FactoryMuff;

abstract class Kind
{

  protected $kind = null;
  protected $model = null;

  public function __construct($kind, $model)
  {
    $this->kind = $kind;
    $this->model = $model;
  }

  public static function detect($kind, $model = null)
  {
    if($kind instanceof \Closure) {
      return new Kind\Closure($kind, $model);
    }
    elseif (is_string($kind)) {

      $available_kinds = array(
        'call',
        'closure',
        'date',
        'email',
        'factory',
        'integer',
        'none',
        'string',
        'text',
      );

      $class = '\\Zizaco\\FactoryMuff\\Kind\\None';
      foreach ($available_kinds as $available_kind)
      {
        if (substr($kind, 0, strlen($available_kind)) === $available_kind) {
          $class = '\\Zizaco\\FactoryMuff\\Kind\\' . ucfirst($available_kind);
          break;
        }
      }

      return new $class($kind, $model);
    }
  }

  public function getOption($index, $default = null)
  {
    $options = $this->getOptions();
    if (isset($options[$index])) {
      return $options[$index];
{'fraction_non_alphanumeric': 0.18077884958913898, 'fraction_numerical': 0.00964630225080386, 'mean_word_length': 2.349282296650718, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '948710', 'n_tokens_mistral': 945, 'n_tokens_neox': 912, 'n_words': 217}