<?php
namespace App\Danoral;

class U
{
    public function __construct(){
        date_default_timezone_set('America/Caracas');
    }

    public static $MES = [
         1 => 'Enero',
         2 => 'Febrero',
         3 => 'Marzo',
         4 => 'Abril',
         5 => 'Mayo',
         6 => 'Junio',
         7 => 'Julio',
         8 => 'Agosto',
         9 => 'Septiembre',
        10 => 'Octubre',
        11 => 'Septiembre',
        12 => 'Diciembre'
    ];


    public $log;
    public $isEcho = true;
    public $logList = [];

    public static function getMesTxt($mes){
        return ($mes<10?'0':'').strval($mes);
    }
    public static function getCodBancoTxt($codBanco){
        return '0'.(($codBanco<10)?'0':'').strval($codBanco);
    }

    /** 
     * 62 digitos
     * C(62,6) = 99795696 
     */
    public static function generate_string($strength = 10) {
        $permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

        $input_length = strlen($permitted_chars);
        $random_string = '';
        for($i = 0; $i < $strength; $i++) {
            $random_character = $permitted_chars[mt_rand(0, $input_length - 1)];
            $random_string .= $random_character;
        }

        return $random_string;
    }

    public function eLinea($linea, $isEOL = true){
        $linea = '['. date("Y-m-d H:i:s") .'] '. $linea;
        $this->log .= $linea . ($isEOL?'<br>':'');
        $this->logList[] = $linea;
        if($this->isEcho){
            echo $linea . PHP_EOL;
        }
    }

    public function addLogList($addLogList) {
        $this->logList = array_merge($this->logList, $addLogList);
    }


}
// Output: iNCHNGzByPjhApvn7XBD
//echo generate_string($permitted_chars, 20);
