Telegram\Bot\Api::isValidFileOrUrl PHP Method

isValidFileOrUrl() protected method

Determines if the string passed to be uploaded is a valid file on the local file system, or a valid remote URL.
protected isValidFileOrUrl ( string $name, string $contents ) : boolean
$name string
$contents string
return boolean
    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);
    }