Completed
Push — master ( 5fe409...71e3f4 )
by Marin
02:59
created

Post_Meta_Datastore::get_id()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
ccs 0
cts 2
cp 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php 
2
3
namespace Carbon_Fields\Datastore;
4
5
use Carbon_Fields\Field\Field;
6
7
/**
8
 * Post meta (custom fields) datastore class.
9
 */
10
class Post_Meta_Datastore extends Meta_Datastore {
11
	/**
12
	 * ID of the post.
13
	 *
14
	 * @var int
15
	 */
16
	protected $post_id;
17
18
	/**
19
	 * Retrieve the type of meta data.
20
	 *
21
	 * @return string
22
	 */
23
	public function get_meta_type() {
24
		return 'post';
25
	}
26
27
	/**
28
	 * Retrieve the meta table name to query.
29
	 *
30
	 * @return string
31
	 */
32
	public function get_table_name() {
33
		global $wpdb;
34
		return $wpdb->postmeta;
35
	}
36
37
	/**
38
	 * Retrieve the meta table field name to query by.
39
	 *
40
	 * @return string
41
	 */
42
	public function get_table_field_name() {
43
		return 'post_id';
44
	}
45
46
	/**
47
	 * Set the post ID of the datastore.
48
	 *
49
	 * @param int $id ID of the post.
50
	 */
51
	public function set_id( $id ) {
52
		$this->post_id = $id;
53
	}
54
55
	/**
56
	 * Retrieve the post ID of the datastore.
57
	 * 
58
	 * @return int ID of the post.
59
	 */
60
	public function get_id() {
61
		return $this->post_id;
62
	}
63
}
64