Completed
Branch sideload-all-language-files (d12b05)
by
unknown
52:19 queued 43:17
created

URLValidator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 4 1
1
<?php
2
namespace EventEspresso\core\services\validators;
3
4
/**
5
 * Class URLValidator
6
 *
7
 * Replacement for `filter_var($url, FILTER_VALIDATE_URL)` because of all the problems mentioned on
8
 * https://d-mueller.de/blog/why-url-validation-with-filter_var-might-not-be-a-good-idea/.
9
 * Why not just use `esc_url_raw()`? Yes, we could. But it's better to consolidate the validation logic in case it needs
10
 * to be tweaked someday.
11
 *
12
 * @package     Event Espresso
13
 * @author         Mike Nelson
14
 * @since         4.9.68.p
15
 *
16
 */
17
class URLValidator
18
{
19
    /**
20
     * Returns whether or not the URL is valid
21
     * @since 4.9.68.p
22
     * @param $url
23
     * @return boolean
24
     */
25
    public function isValid($url)
26
    {
27
        return  esc_url_raw($url) === $url;
28
    }
29
}
30
// End of file URLValidator.php
31
// Location: ${NAMESPACE}/URLValidator.php
32