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

HTML_QuickForm_Rule_InternalUrl::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
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