Gush\Adapter\DefaultConfigurator::validateUrl PHP Méthode

validateUrl() public méthode

Validates if the value is none-empty and a valid URL.
public validateUrl ( string $url ) : string
$url string
Résultat string
    public function validateUrl($url)
    {
        if (empty($url)) {
            throw new \InvalidArgumentException('The field cannot be empty.');
        }
        if (!filter_var($url, FILTER_VALIDATE_URL)) {
            throw new \InvalidArgumentException('The field requires a valid URL.');
        }
        return $url;
    }