Changes directory path to the file / directory.
public changePath ( string $path ) : |
||
$path | string | |
return |
/** * {@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; }
public function testChangePath() { $srcFileInfo = new FileInfo(__FILE__); $dstFileInfo = $srcFileInfo->changePath(__DIR__ . '/uploads/'); $this->assertEquals(__DIR__ . '/uploads', $dstFileInfo->getPath()); $this->assertNotSame($srcFileInfo, $dstFileInfo); }