private function myDirectoryToString(string $directorySeparator, ?callable $stringEncoder = null): string
    {
        $result = '';

        if ($this->myAboveBaseLevel > 0) {
            $result .= str_repeat('..' . $directorySeparator, $this->myAboveBaseLevel);
        }

        if ($this->myIsAbsolute) {
            $result .= $directorySeparator;
        }

        $result .= implode($directorySeparator, $stringEncoder !== null ?
            array_map($stringEncoder, $this->myDirectoryParts) :
            $this->myDirectoryParts);

        if (count($this->myDirectoryParts) > 0) {
            $result .= $directorySeparator;
        }

        return $result;
    }