directorySeparator = $directorySeparator; } /** * Get the parent directory for a given path. * * @param string $path * * @return string */ public function __invoke(string $path) { $parentDir = Str::explode($path, $this->directorySeparator)->map( static function (string $segment): string { return rawurlencode($segment); } )->filter(static function (?string $value): bool { return $value !== null; })->slice(0, -1)->implode($this->directorySeparator); if ($parentDir === '') { return '.'; } return sprintf('?dir=%s', $parentDir); } }