FileNamingResolver\NamingStrategy\HashNamingStrategy::provideName PHP Method

provideName() public method

public provideName ( FileInfo $srcFileInfo )
$srcFileInfo FileNamingResolver\FileInfo
    public function provideName(FileInfo $srcFileInfo)
    {
        $string = $this->generateUniqueString();
        $hash = hash($this->algorithm, $string);
        $dstFileInfo = $this->provideNameByHash($srcFileInfo, $hash);
        return $dstFileInfo;
    }

Usage Example

 public function testProvideName()
 {
     $srcFileInfo = new FileInfo(__FILE__);
     $strategy = new HashNamingStrategy();
     $pathname = $strategy->provideName($srcFileInfo);
     $this->assertInternalType('string', $pathname);
     $this->assertStringStartsWith($srcFileInfo->getPath(), $pathname);
     $this->assertStringEndsNotWith($srcFileInfo->getFilename(), $pathname);
 }
HashNamingStrategy