/** * testRandomPath * * @return void */ public function testRandomPath() { $this->skipIf(PHP_INT_SIZE === 8); $result = StorageUtils::randomPath('someteststring'); $this->assertEquals($result, '38' . DS . '88' . DS . '98' . DS); $result = StorageUtils::randomPath('file-storage-3'); $this->assertEquals($result, '48' . DS . '75' . DS . '05' . DS); }
/** * Generates a semi-random file system path * * @deprecated Don't use this anymore but it is still used by two legacy listeners :( * @param string $type * @param string $string * @param boolean $idFolder * @return string */ public function fsPath($type, $string, $idFolder = true) { $string = str_replace('-', '', $string); $path = $type . DS . StorageUtils::randomPath($string); if ($idFolder) { $path .= $string . DS; } return $path; }
/** * Builds a semi-random path based on a given string to avoid having thousands of files * or directories in one directory. This would result in a slowdown on most file systems. * * Works up to 5 level deep * * @deprecated Use the randomPath() method from the BasePathBuilder instead. * @link https://www.box.com/blog/crc32-checksums-the-good-the-bad-and-the-ugly/ * @throws InvalidArgumentException * @param mixed $string * @param integer $level 1 to 5 * @return null|string */ public static function randomPath($string, $level = 3) { return StorageUtils::randomPath($string, $level); }