protected function isFilename($source): bool
    {
        if (!is_string($source)) {
            return false;
        }

        if (!preg_match('/[^A-Za-z0-9.#\\-$]/', $source)) {
            return false;
        }

        //To filter out binary strings
        $source = strval(str_replace("\0", "", $source));

        return file_exists($source);
    }