random( $size ); $toGenerate = $size - strlen( $random ); while( $toGenerate > 0 ) { if ( $toGenerate > 5 ) $subGenerate = 5; else $subGenerate = $toGenerate; $random .= \substr( \strrev( \uniqid() ) ,0 ,$subGenerate ); $toGenerate = $size - \strlen( $random ); } return $random; } // \darkphp\randomizer\DwRandomizer::randomize( $size ); public static function randomize( int $size = 1 ) : string { return \darkphp\randomizer\DwRandomizer::randomBase62( $size ); } // \darkphp\randomizer\DwRandomizer::progressiveUUID( $array ); public static function progressiveUUID( array $array ) : string { $progressiveUUID=self::randomize( ); while( isset( $array[ $progressiveUUID ] ) ) $progressiveUUID .= self::randomize( ); return $progressiveUUID; } // \darkphp\randomizer\DwRandomizer::progressiveInArrayUUID( $array ); public static function progressiveInArrayUUID( array $array ) : string { $progressiveUUID=self::randomize( ); while( \in_array( $progressiveUUID ,$array ) ) $progressiveUUID .= self::randomize( ); return $progressiveUUID; } // TODO : random_bytes() encodé en hex ou base64 // \darkphp\randomizer\DwRandomizer::gen_uuid( ); public static function gen_uuid() { $uuid = array( 'time_low' => 0 ,'time_mid' => 0 ,'time_hi' => 0 ,'clock_seq_hi' => 0 ,'clock_seq_low' => 0 ,'node' => array() ); $uuid['time_low'] = mt_rand(0, 0xffff) + (mt_rand(0, 0xffff) << 16); $uuid['time_mid'] = mt_rand(0, 0xffff); $uuid['time_hi'] = (4 << 12) | (mt_rand(0, 0x1000)); $uuid['clock_seq_hi'] = (1 << 7) | (mt_rand(0, 128)); $uuid['clock_seq_low'] = mt_rand(0, 255); for ($i = 0; $i < 6; $i++) { $uuid['node'][$i] = mt_rand(0, 255); } $uuid = sprintf('%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x' ,$uuid['time_low'] ,$uuid['time_mid'] ,$uuid['time_hi'] ,$uuid['clock_seq_hi'] ,$uuid['clock_seq_low'] ,$uuid['node'][0] ,$uuid['node'][1] ,$uuid['node'][2] ,$uuid['node'][3] ,$uuid['node'][4] ,$uuid['node'][5] ); return $uuid; } /* public function getClassName( bool $fqcn=null ) : string { return self::getStaticClassName( $fqcn ); } //*/ public static function getStaticClassName( bool $fqcn=null ) : string { return $fqcn ? parent::getStaticClassName( $fqcn ).self::CLASS_SEPARATOR.__CLASS__ : __CLASS__ ; } } ?>