Microweber\Utils\Files::rglob PHP Method

rglob() public method

Recursive glob().
public rglob ( integer | string $pattern = '*', integer $flags, string $path = '' ) : mixed
$pattern integer | string the pattern passed to glob()
$flags integer the flags passed to glob()
$path string the path to scan
return mixed an array of files in the given path matching the pattern.
    public function rglob($pattern = '*', $flags = 0, $path = '')
    {
        if (!$path && ($dir = dirname($pattern)) != '.') {
            if ($dir == '\\' || $dir == '/') {
                $dir = '';
            }
            return $this->rglob(basename($pattern), $flags, $dir . DS);
        }
        if (stristr($path, '_notes') or stristr($path, '.git') or stristr($path, '.svn')) {
            return false;
        }
        $paths = glob($path . '*', GLOB_ONLYDIR | GLOB_NOSORT);
        $files = glob($path . $pattern, $flags);
        if (is_array($paths)) {
            foreach ($paths as $p) {
                $temp = array();
                if (is_dir($p) and is_readable($p)) {
                    $temp = $this->rglob($pattern, false, $p . DS);
                }
                if (is_array($temp) and is_array($files)) {
                    $files = array_merge($files, $temp);
                } elseif (is_array($temp)) {
                    $files = $temp;
                }
            }
        }
        return $files;
    }