protected function nameHasExtension(string $name, array $sortedExtensions) : bool
    {
        foreach ($sortedExtensions as $extension) {
            $lengthDifference = strlen($name) - strlen($extension);

            if ($lengthDifference > 0 && strpos($name, $extension, $lengthDifference) !== false) {
                return true;
            }
        }

        return false;
    }