<commit_before><?php

class dmArray
{

  /*
   * Sets each array key to its corresponding value
   */
  public static function valueToKey($array)
  {
    $tmp = array();
    foreach($array as $value)
    {
      $tmp[$value] = $value;
    }
    unset($array);
    return $tmp;
  }

  /*
   * Returns the value of an array, if the key exists
   */
  public static function get($array, $key, $default = null, $defaultIfNull = false)
  {
    if (!is_array($array))
    {
      return $default;
    }

    if (false === $defaultIfNull)
    {
      if(isset($array[$key]))
      {
        return $array[$key];
      }
      else
      {
        return $default;
      }
    }

    if(!empty($array[$key]))
    {
      return $array[$key];
    }
    else
    {
      return $default;
    }
  }


  // retourne la première valeur d'un tableau
  public static function first($array)
  {
    if(!is_array($array))
    {
      return $array;
    }

    if(empty($array))
    {
      return null;
    }

    $a = array_shift($array);
    unset($array);

    return $a;
  }

  // retourne la dernière valeur d'un tableau
  public static function last($array)
  {
    if(!is_array($array))
    {
      return $array;
    }

    if(empty($array))
    {
      return null;
    }

    $a = array_pop($array);
    unset($array);

    return $a;
  }

  // retourne la première clé d'un tableau
  public static function firstKey($array)
  {
    return self::firstEntryIn(array_keys($array));
  }

  // retourne les premières valeurs d'un tableau
  public static function firsts($array, $nb)
  {
    if(!is_array($array))
    {
      return $array;
    }

    if(empty($array))
    {<commit_msg>[Diem] - fixed comments<commit_after><?php

class dmArray
{

  /*
   * Sets each array key to its corresponding value
   */
  public static function valueToKey($array)
  {
    $tmp = array();
    foreach($array as $value)
    {
      $tmp[$value] = $value;
    }
    unset($array);
    return $tmp;
  }

  /*
   * Returns the value of an array, if the key exists
   */
  public static function get($array, $key, $default = null, $defaultIfNull = false)
  {
    if (!is_array($array))
    {
      return $default;
    }

    if (false === $defaultIfNull)
    {
      if(isset($array[$key]))
      {
        return $array[$key];
      }
      else
      {
        return $default;
      }
    }

    if(!empty($array[$key]))
    {
      return $array[$key];
    }
    else
    {
      return $default;
    }
  }

  // get first value of an array
  public static function first($array)
  {
    if(!is_array($array))
    {
      return $array;
    }

    if(empty($array))
    {
      return null;
    }

    $a = array_shift($array);
    unset($array);

    return $a;
  }

  // get last value of an array
  public static function last($array)
  {
    if(!is_array($array))
    {
      return $array;
    }

    if(empty($array))
    {
      return null;
    }

    $a = array_pop($array);
    unset($array);

    return $a;
  }

  // get first key of an array
  public static function firstKey($array)
  {
    return self::firstEntryIn(array_keys($array));
  }

  // get first valueS of an array
  public static function firsts($array, $nb)
  {
    if(!is_array($array))
    {
      return $array;
    }

    if(empty($array))
    {
{'fraction_non_alphanumeric': 0.14069591527987896, 'fraction_numerical': 0.0, 'mean_word_length': 2.0164233576642334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6418934', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1116, 'n_words': 266}