code: public static function dirname($path)
      {
          $pos = mb_strrpos(str_replace('\\', '/', $path), '/');
          if ($pos !== false) {
              return mb_substr($path, 0, $pos);
          }
  
          return '';
      }
docs: Returns parent directory's path.
  This method is similar to `dirname()` except that it will treat
  both \ and / as directory separators, independent of the operating system.
  
  @param string $path A path string.
  @return string the parent directory's path.
  @see https://secure.php.net/manual/en/function.basename.php