protected function isValidFileOrUrl($name, $contents)
    {
        //Don't try to open a url as an actual file when using this method to setWebhook.
        if ($name == 'url') {
            return false;
        }

        //If a certificate name is passed, we must check for the file existing on the local server,
        // otherwise telegram ignores the fact it wasn't sent and no error is thrown.
        if ($name == 'certificate') {
            return true;
        }

        //Is the content a valid file name.
        if (is_readable($contents)) {
            return true;
        }

        //Is the content a valid URL
        return filter_var($contents, FILTER_VALIDATE_URL);
    }