FileNamingResolver\NamingStrategy\DatetimeNamingStrategy::provideName PHP Méthode

provideName() public méthode

public provideName ( FileInfo $srcFileInfo )
$srcFileInfo FileNamingResolver\FileInfo
    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;
    }

Usage Example

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