for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace FileNamingResolver\NamingStrategy;
use FileNamingResolver\FileInfo;
/**
* @author Victor Bocharsky <[email protected]>
*/
class ContentHashNamingStrategy extends AbstractHashNamingStrategy
{
* {@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;