/** * {@inheritdoc} * * @throws \InvalidArgumentException If source file does not exist */ public function provideName(FileInfo $srcFileInfo) { if (!$srcFileInfo->isFile()) { throw new \InvalidArgumentException(sprintf('The source file does not exist on "%s" specified path.', $srcFileInfo->toString())); } $hash = hash_file($this->algorithm, $srcFileInfo->toString()); $dstFileInfo = $this->provideNameByHash($srcFileInfo, $hash); return $dstFileInfo; }
/** * {@inheritdoc} */ public function provideName(FileInfo $srcFileInfo) { $dstFileInfo = $srcFileInfo; $strategies = $this->isReverseMode() ? array_reverse($this->strategies, true) : $this->strategies; foreach ($strategies as $strategy) { $filename = (string) $strategy->provideName($dstFileInfo); $dstFileInfo = new FileInfo($filename); } return $dstFileInfo->toString(); }
public function testToString() { $fileInfo = new FileInfo(__FILE__); $this->assertEquals(__FILE__, $fileInfo->toString()); }