コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function provideName(FileInfo $srcFileInfo)
 {
     $datetime = \DateTime::createFromFormat('U.u', microtime(true));
     $pathSuffix = FileInfo::purifyPath($datetime->format($this->dirFormat));
     $dstFileInfo = $srcFileInfo->changePath($srcFileInfo->getPath() . FileInfo::SEPARATOR_DIRECTORY . $pathSuffix)->changeBasename($datetime->format($this->fileFormat));
     return $dstFileInfo;
 }
コード例 #2
0
 /**
  * @param FileInfo $srcFileInfo
  * @param string $hash
  *
  * @return FileInfo
  */
 public function provideNameByHash(FileInfo $srcFileInfo, $hash)
 {
     $pathSuffixParts = array();
     for ($i = 0; $i < $this->partCount; $i++) {
         $pathSuffixParts[] = substr($hash, $i * $this->partLength, $this->partLength);
     }
     $name = substr($hash, $i * $this->partLength);
     $pathSuffix = implode(FileInfo::SEPARATOR_DIRECTORY, $pathSuffixParts);
     $dstFileInfo = $srcFileInfo->changeBasename($name)->changePath($srcFileInfo->getPath() . FileInfo::SEPARATOR_DIRECTORY . $pathSuffix);
     return $dstFileInfo;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function provideName(FileInfo $srcFileInfo)
 {
     $string = $this->generateUniqueString();
     $hash = hash($this->algorithm, $string);
     $pathSuffixParts = array();
     for ($i = 0; $i < $this->partCount; $i++) {
         $pathSuffixParts[] = substr($hash, $i * $this->partLength, $this->partLength);
     }
     $name = substr($hash, $i * $this->partLength);
     $pathSuffix = implode(FileInfo::SEPARATOR_DIRECTORY, $pathSuffixParts);
     $dstFileInfo = $srcFileInfo->changeBasename($name)->changePath($srcFileInfo->getPath() . FileInfo::SEPARATOR_DIRECTORY . $pathSuffix);
     return $dstFileInfo->toString();
 }