private static function getLeadingDir(string $pattern): string
  {
    $dir = $pattern;

    $pos = strpos($dir, '*');
    if ($pos!==false) $dir = substr($dir, 0, $pos);

    $pos = strpos($dir, '?');
    if ($pos!==false) $dir = substr($dir, 0, $pos);

    $pos = strrpos($dir, '/');
    if ($pos!==false)
    {
      $dir = substr($dir, 0, $pos);
    }
    else
    {
      $dir = '.';
    }

    return $dir;
  }
private static function getLeadingDir(string $pattern): string
  {
    $dir = $pattern;

    $pos = strpos($dir, '*');
    if ($pos!==false) $dir = substr($dir, 0, $pos);

    $pos = strpos($dir, '?');
    if ($pos!==false) $dir = substr($dir, 0, $pos);

    $pos = strrpos($dir, '/');
    if ($pos!==false)
    {
      $dir = substr($dir, 0, $pos);
    }
    else
    {
      $dir = '.';
    }

    return $dir;
  }
private static function getLeadingDir ( string $ pattern ) : string { $ dir = $ pattern ; $ pos = strpos ( $ dir , '*' ) ; if ( $ pos !== false ) $ dir = substr ( $ dir , 0 , $ pos ) ; $ pos = strpos ( $ dir , '?' ) ; if ( $ pos !== false ) $ dir = substr ( $ dir , 0 , $ pos ) ; $ pos = strrpos ( $ dir , '/' ) ; if ( $ pos !== false ) { $ dir = substr ( $ dir , 0 , $ pos ) ; } else { $ dir = '.' ; } return $ dir ; }
Returns the leading directory without wild cards of a pattern.

@param string $pattern The pattern.

@return string
Returns the leading directory without wild cards of a pattern .