Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Url Class Reference

Public Member Functions

 isValid ($value, array $allowedSchemes=[])
 

Detailed Description

Class Url validates URL and checks that it has allowed scheme

Definition at line 11 of file Url.php.

Member Function Documentation

◆ isValid()

isValid (   $value,
array  $allowedSchemes = [] 
)

Validate URL and check that it has allowed scheme

Parameters
string$value
array$allowedSchemes
Returns
bool

Definition at line 20 of file Url.php.

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  }
$value
Definition: gender.phtml:16

The documentation for this class was generated from the following file: