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

Wordlift_Sanitizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 21
rs 10
wmc 3
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A sanitize_url() 0 14 3
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
}