src/Filesystem/HashFile.php
public static function create(string $extension = ''): array
    {
        static::init();
        $filePath = $fileName = '';
        if (static::verifyPath(static::$hashFileDir)) {
            $exists = true;
            while ($exists === true) {
                $hash = Random::hash();
                $hashDir = \implode('/', \str_split(\substr($hash, 0, static::$hashFileDirDepth), 1));
                $filePath = static::normalizePath(\sprintf('%s%s', static::$hashFileDir, $hashDir));
                $filePath .= DIRECTORY_SEPARATOR;
                $fileName = \sprintf('%s.%s', $hash, $extension);
                $exists = File::exists($filePath.$fileName);
            }
        }
        return ['path' => $filePath, 'name' => $fileName];
    }
public static function create(string $extension = ''): array
    {
        static::init();
        $filePath = $fileName = '';
        if (static::verifyPath(static::$hashFileDir)) {
            $exists = true;
            while ($exists === true) {
                $hash = Random::hash();
                $hashDir = \implode('/', \str_split(\substr($hash, 0, static::$hashFileDirDepth), 1));
                $filePath = static::normalizePath(\sprintf('%s%s', static::$hashFileDir, $hashDir));
                $filePath .= DIRECTORY_SEPARATOR;
                $fileName = \sprintf('%s.%s', $hash, $extension);
                $exists = File::exists($filePath.$fileName);
            }
        }
        return ['path' => $filePath, 'name' => $fileName];
    }
public static function create ( string $ extension = '' ) : array { static :: init ( ) ; $ filePath = $ fileName = '' ; if ( static :: verifyPath ( static :: $ hashFileDir ) ) { $ exists = true ; while ( $ exists === true ) { $ hash = Random :: hash ( ) ; $ hashDir = \ implode ( '/' , \ str_split ( \ substr ( $ hash , 0 , static :: $ hashFileDirDepth ) , 1 ) ) ; $ filePath = static :: normalizePath ( \ sprintf ( '%s%s' , static :: $ hashFileDir , $ hashDir ) ) ; $ filePath .= DIRECTORY_SEPARATOR ; $ fileName = \ sprintf ( '%s.%s' , $ hash , $ extension ) ; $ exists = File :: exists ( $ filePath . $ fileName ) ; } } return [ 'path' => $ filePath , 'name' => $ fileName ] ; }
Returns unique hash file name.

@param string $extension
@return array
Returns unique hash file name .