protected function fileEndsWith(string $haystack, string $needle): bool
    {
        $length = strlen($needle);
        if (strlen($haystack) < $length) {
            return $this->fileEndsWith($needle, $haystack);
        }

        $haystack = str_replace('\\', '/', $haystack);
        $needle = str_replace('\\', '/', $needle);
        
        return (substr($haystack, -$length) === $needle);
    }