Completed
Push — develop ( 8dee00...a73902 )
by David
03:37
created

Wordlift_Sanitizer::sanitize_url()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 4
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 14
rs 9.4285
1
<?php
2
3
/**
4
 */
5
class Wordlift_Sanitizer {
6
7
	/**
8
	 * Only accept URIs
9
	 */
10
	public static function sanitize_url( $value ) {
11
12
		// Initially this function used also filter_var( $value, FILTER_VALIDATE_URL )
13
		// but URLs with UTF-8 characters are not valid. We store those anyway in the DB as it's up to the browser
14
		// to do proper url encoding when requesting the URL.
15
		//
16
		// see also http://stackoverflow.com/questions/2137080/php-filter-var-filter-validate-url
17
18
		if ( ! is_null( $value ) && $value !== '' ) {
19
			return $value;
20
		}
21
22
		return null;
23
	}
24
25
}