Completed
Push — develop ( 1b1461...9efb3c )
by David
03:28
created

Wordlift_Property_Service::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Define the Wordlift_Property_Service abstract class.
5
 *
6
 * @since 3.6.0
7
 */
8
9
/**
10
 * Wordlift_Property_Service provides basic functions and declarations for
11
 * properties that extend WL's schema.
12
 *
13
 * @since 3.6.0
14
 */
15
abstract class Wordlift_Property_Service {
16
17
	protected $params;
18
19
	// TODO: check that this is relative to the extending class.
20
	protected static $instance;
21
22
	public function __construct() {
23
		// Add a reference to the validation function.
24
		$this->params['sanitize'] = array( $this, 'sanitize' );
25
26
		static::$instance = $this;
27
	}
28
29
	/**
30
	 * Get the field singleton.
31
	 *
32
	 * @since 3.6.0
33
	 * @return \Wordlift_Schema_Url_Property_Service The singleton instance.
34
	 */
35
	public static function get_instance() {
36
37
		return static::$instance;
38
	}
39
40
	/**
41
	 * Get the value for the specified post/entity.
42
	 *
43
	 * @since 3.6.0
44
	 *
45
	 * @param int $post_id The post id.
46
	 *
47
	 * @return mixed
48
	 */
49
	public abstract function get( $post_id );
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
50
51
	/**
52
	 * Sanitize the provided value.
53
	 *
54
	 * @since 3.6.0
55
	 *
56
	 * @param mixed $value The value to sanitize.
57
	 *
58
	 * @return mixed|NULL The sanitized value or NULL avoid saving this value (see {@link WL_Metabox_Field}).
59
	 */
60
	public abstract function sanitize( $value );
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
61
62
	/**
63
	 * Get the field parameters.
64
	 *
65
	 * @since 3.6.0
66
	 * @return array An array of parameters.
67
	 */
68
	public function get_params() {
69
70
		return $this->params;
71
	}
72
73
}
74