return $f->getBasename($suffix);
}
- public static function hashFileAttributes($path){
- return hash('sha256',$path.'/$$'.filesize($path).'///'.filemtime($path));
+ public static function hashFileAttributes($path)
+ {
+ return hash('sha256', $path . '/$$' . filesize($path) . '///' . filemtime($path));
}
public static function copyFile($from, $to, $hashAlgo = false)
* @param ...$files string
* @return string|null
*/
- public static function firstThatExists(...$files){
+ public static function firstThatExists(...$files)
+ {
foreach ($files as $file) {
- if(file_exists($file)){
+ if (file_exists($file)) {
return $file;
}
}
return null;
}
+ public static function recursiveReplaceStringInDir($path, $replace = [])
+ {
+ $files=self::getRecursiveDirectoryIterator($path);
+ foreach ($files as $file) {
+ /** @var $file \SplFileInfo */
+ if($file->isDir()){
+ continue;
+ }
+ $c=file_get_contents($file->getPathname());
+ foreach ($replace as $k=>$v) {
+ $c=str_replace($k,$v,$c);
+ }
+ file_put_contents($file->getPathname(),$c);
+ }
+ }
+
}
\ No newline at end of file