public function withoutExtension(string $path, string $extension = null): string
    {
        $path = $this->getTransformedPath($path);

        if ($extension !== null) {
            // remove extension and trailing dot
            return \rtrim(\basename($path, $extension), '.');
        }

        return \pathinfo($path, \PATHINFO_FILENAME);
    }