Passed
Push — 1.11.x ( 5018a2...14798e )
by Yannick
10:31
created

HTML_QuickForm_Rule_InternalUrl   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 2
c 1
b 0
f 0
dl 0
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 3 1
1
<?php
2
3
/**
4
 * Abstract base class for QuickForm validation rules.
5
 */
6
7
/**
8
 * Validate internal urls (URLs without the domain).
9
 */
10
class HTML_QuickForm_Rule_InternalUrl extends HTML_QuickForm_Rule
11
{
12
    /**
13
     * Validates internal url.
14
     * We cheat a little by using the adding the domain as prefix to use the domain validation process of filter_var().
15
     *
16
     * @param string $url
17
     *
18
     * @return bool returns true if valid, false otherwise
19
     */
20
    public function validate($url, $options)
21
    {
22
        return (bool) filter_var(api_get_path(WEB_PATH).$url, FILTER_VALIDATE_URL);
23
    }
24
}
25