Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Url.php
Go to the documentation of this file.
1 <?php
7 
11 class Url
12 {
20  public function isValid($value, array $allowedSchemes = [])
21  {
22  $isValid = true;
23 
24  if (!filter_var($value, FILTER_VALIDATE_URL)) {
25  $isValid = false;
26  }
27 
28  if ($isValid && !empty($allowedSchemes)) {
29  $url = parse_url($value);
30  if (empty($url['scheme']) || !in_array($url['scheme'], $allowedSchemes)) {
31  $isValid = false;
32  }
33  }
34 
35  return $isValid;
36  }
37 }
isValid($value, array $allowedSchemes=[])
Definition: Url.php:20
$value
Definition: gender.phtml:16