<commit_before><?php
/**
 *
 */
class Curiosity{

   private static $_curiosity;

   public static function singleton(){
      if (self::$_curiosity) { return self::$_curiosity; }
      else {
         $class = __CLASS__;
         self::$_curiosity = new $class();
         return self::$_curiosity;
      }
   }

   public static function getValidationMessages(){
      $curiosity = self::singleton();
      $messages = [
             "required"    =>  "El campo :attribute es requerido",
             "alpha"       =>  "Solo puedes ingresar letras",
             "date"        =>  "Formato de fecha invalido",
             "numeric"     =>  "Solo se permiten digitos",
             "email"       =>  "Ingresa un formato de correo valido",
             "unique"      =>  "Este usuario ya existe",
             "integer"     =>  "Solo se permiten numeros enteros",
             "exists"      =>  "El campo :attribute no existe en el sistema",
             "unique"      =>  "El campo :attribute no esta disponible intente con otro valor",
             "integer"     =>  "Solo puedes ingresar numeros enteros",
             "same"        =>  "Las contraseñas no coinciden",
             "after"       =>  "La fecha de expiracion es incorrecta, no puedes ingresar fechas inferiores al día de hoy",
       ];
       return $messages;
   }

   public static function makeRandomName($rand = false, $date = false){
      $curiosity = self::singleton();
      $characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
      $limit = 5;
		$word = "";
		for($i=0; $i < $limit; $i++) { $word .= substr($characters, rand(0, strlen($characters)), 1); }
      if ($rand) { $word."_".rand(); }
      if ($date) { $word."_".date("y").date("m").date("d"); }
		return $word;
   }

   public static function extractZip($inputFile, $typeAndFolder = [], $boolean = 'yes'){
      $curiosity = self::singleton();
      try{
         if($inputFile != null){
            // is the zip file type?
            if($inputFile->getClientOriginalExtension() == 'zip'){
               // We'll save the name in the var $log
               $log = $inputFile->getClientOriginalName();
               // ask in one conditional if the folder exists
               if(!file_exists(public_path()."/packages/saveFilesZipTemp/")){
                  $dirTempJuegoZip = mkdir(public_path()."/packages/saveFilesZipTemp/");
               }
               // Save the directory to save the zip files
               $directoryPath = public_path()."/packages/saveFilesZipTemp/";
               // save the file into var $file
               $file = $inputFile;
               // move the file to the $directoryPath
               $file->move($directoryPath, $log);
               // the var $routeZIP is the route of Zip
               $routeZIP = $directoryPath.$log;
               // Extract the file in the route into parameter
               $extraccion = $this->extractFile($routeZIP, $typeAndFolder, $boolean);
               if($extraccion[0] == true){
                  return $extraccion;
               }
               else {
                  return false;
               }
            }
            else{
               return false;
            }
         }
         else{
            return false;
         }
      }
      catch(Exception $ex){
         return Response::json(array(0=>'ERROR: '.$ex));
      }
   }

   public static function getFileExtension($file = ""){
      $curiosity = self::singleton();
      if ($file != ""){
         $parts = explode(".", $file);
         $ext = end($parts);
         return $ext;
      }
      else{
         return null;
      }
   }

   public static function bubleSortObject($array = [], $attr = "", $order = 'asc'){
      for ($i=0; $i < count($array); $i++) {
         for ($e = 0; $e < count($array); $e++) {
            if ($order == 'asc'){
               if ($array[$i][$attr] < $array[$e][$attr]){
                  $temp = $array[$i];
                  $array[$i] = $array[$e];
                  $array[$e] = $temp;
               }
            }
            else{
               if ($array[$i][$attr] > $array[$e][$attr]){
                  $temp = $array[$i];
                  $array[$i] = $array[$e];
                  $array[$e] = $temp;
               }
            }
         }
      }
      return $array;
   }

   public static function makeArrayByObject($obj){
      $arr = array();
		foreach ($obj as $key => $value) { $arr[$key] = $value; }
      return $arr;
   }<commit_msg>Y se codifica en la clase<commit_after><?php
/**
 *
 */
class Curiosity{

   private static $_curiosity;

   public static function singleton(){
      if (self::$_curiosity) { return self::$_curiosity; }
      else {
         $class = __CLASS__;
         self::$_curiosity = new $class();
         return self::$_curiosity;
      }
   }

   public static function getValidationMessages(){
      $curiosity = self::singleton();
      $messages = [
             "required"    =>  "El campo :attribute es requerido",
             "alpha"       =>  "Solo puedes ingresar letras",
             "date"        =>  "Formato de fecha invalido",
             "numeric"     =>  "Solo se permiten digitos",
             "email"       =>  "Ingresa un formato de correo valido",
             "unique"      =>  "Este usuario ya existe",
             "integer"     =>  "Solo se permiten numeros enteros",
             "exists"      =>  "El campo :attribute no existe en el sistema",
             "unique"      =>  "El campo :attribute no esta disponible intente con otro valor",
             "integer"     =>  "Solo puedes ingresar numeros enteros",
             "same"        =>  "Las contraseñas no coinciden",
             "after"       =>  "La fecha de expiracion es incorrecta, no puedes ingresar fechas inferiores al día de hoy",
       ];
       return $messages;
   }

   public static function makeRandomName($rand = false, $date = false){
      $curiosity = self::singleton();
      $characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
      $limit = 5;
		$word = "";
		for($i=0; $i < $limit; $i++) { $word .= substr($characters, rand(0, strlen($characters)), 1); }
      if ($rand) { $word."_".rand(); }
      if ($date) { $word."_".date("y").date("m").date("d"); }
		return $word;
   }

   public static function extractZip($inputFile, $typeAndFolder = [], $boolean = 'yes'){
      $curiosity = self::singleton();
      try{
         if($inputFile != null){
            // is the zip file type?
            if($inputFile->getClientOriginalExtension() == 'zip'){
               // We'll save the name in the var $log
               $log = $inputFile->getClientOriginalName();
               // ask in one conditional if the folder exists
               if(!file_exists(public_path()."/packages/saveFilesZipTemp/")){
                  $dirTempJuegoZip = mkdir(public_path()."/packages/saveFilesZipTemp/");
               }
               // Save the directory to save the zip files
               $directoryPath = public_path()."/packages/saveFilesZipTemp/";
               // save the file into var $file
               $file = $inputFile;
               // move the file to the $directoryPath
               $file->move($directoryPath, $log);
               // the var $routeZIP is the route of Zip
               $routeZIP = $directoryPath.$log;
               // Extract the file in the route into parameter
               $extraccion = $this->extractFile($routeZIP, $typeAndFolder, $boolean);
               if($extraccion[0] == true){
                  return $extraccion;
               }
               else {
                  return false;
               }
            }
            else{
               return false;
            }
         }
         else{
            return false;
         }
      }
      catch(Exception $ex){
         return Response::json(array(0=>'ERROR: '.$ex));
      }
   }

   public static function getFileExtension($file = ""){
      $curiosity = self::singleton();
      if ($file != ""){
         $parts = explode(".", $file);
         $ext = end($parts);
         return $ext;
      }
      else{
         return null;
      }
   }

   public static function bubleSortObject($array = [], $attr = "", $order = 'asc'){
      for ($i=0; $i < count($array); $i++) {
         for ($e = 0; $e < count($array); $e++) {
            if ($order == 'asc'){
               if ($array[$i][$attr] < $array[$e][$attr]){
                  $temp = $array[$i];
                  $array[$i] = $array[$e];
                  $array[$e] = $temp;
               }
            }
            else{
               if ($array[$i][$attr] > $array[$e][$attr]){
                  $temp = $array[$i];
                  $array[$i] = $array[$e];
                  $array[$e] = $temp;
               }
            }
         }
      }
      return $array;
   }

   public static function makeArrayByObject($obj){
      $obj = json_decode(json_encode($obj));
      $arr = array();
		foreach ($obj as $key => $value) { $arr[$key] = $value; }
      return $arr;
   }
{'fraction_non_alphanumeric': 0.14459415050936575, 'fraction_numerical': 0.003943476832073612, 'mean_word_length': 1.6517571884984026, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 41, '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': '4971586', 'n_tokens_mistral': 2699, 'n_tokens_neox': 2608, 'n_words': 665}