|
@@ -20,12 +20,9 @@ use Symfony\Component\HttpFoundation\File\Exception\UnexpectedTypeException;
|
|
|
class TemporaryStorage
|
|
|
{
|
|
|
private $directory;
|
|
|
-
|
|
|
private $secret;
|
|
|
|
|
|
- private $nestingLevels;
|
|
|
-
|
|
|
- public function __construct($secret, $nestingLevels = 3, $directory = null)
|
|
|
+ public function __construct($secret, $directory = null)
|
|
|
{
|
|
|
if (empty($directory)) {
|
|
|
$directory = sys_get_temp_dir();
|
|
@@ -33,12 +30,11 @@ class TemporaryStorage
|
|
|
|
|
|
$this->directory = realpath($directory);
|
|
|
$this->secret = $secret;
|
|
|
- $this->nestingLevels = $nestingLevels;
|
|
|
}
|
|
|
|
|
|
protected function generateHashInfo($token)
|
|
|
{
|
|
|
- return $this->secret . $token;
|
|
|
+ return $this->secret.$token;
|
|
|
}
|
|
|
|
|
|
protected function generateHash($token)
|
|
@@ -54,17 +50,6 @@ class TemporaryStorage
|
|
|
|
|
|
$hash = $this->generateHash($token);
|
|
|
|
|
|
- if (strlen($hash) < $this->nestingLevels) {
|
|
|
- throw new FileException(sprintf(
|
|
|
- 'For %s nesting levels the hash must have at least %s characters', $this->nestingLevels, $this->nestingLevels));
|
|
|
- }
|
|
|
-
|
|
|
- $directory = $this->directory;
|
|
|
-
|
|
|
- for ($i = 0; $i < ($this->nestingLevels - 1); ++$i) {
|
|
|
- $directory .= DIRECTORY_SEPARATOR . $hash{$i};
|
|
|
- }
|
|
|
-
|
|
|
- return $directory . DIRECTORY_SEPARATOR . substr($hash, $i);
|
|
|
+ return $this->directory.DIRECTORY_SEPARATOR.substr($hash, 0, 2).DIRECTORY_SEPARATOR.substr($hash, 2);
|
|
|
}
|
|
|
-}
|
|
|
+}
|