for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SmartWeb\ModuleTesting\Util;
/**
* Class ArrayUtil
*
* @package SmartWeb\ModuleTesting\Util
*/
final class FileUtil
{
* @param string $path
* @param string $dir
* @return string
public static function findParentDir(string $path, string $dir) : string
$path = self::normalizePath($path);
return self::pathContainsDir($path, $dir)
? self::normalizePath($path . DIRECTORY_SEPARATOR . $dir)
: self::findParentDir(self::parentDir($path), $dir);
}
* @return bool
private static function pathContainsDir(string $path, string $dir) : bool
return is_dir($path . DIRECTORY_SEPARATOR . $dir);
private static function parentDir(string $path) : string
return self::normalizePath($path . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
public static function normalizePath(string $path) : string
return (string)str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $path);