Completed
Push — master ( 5db201...585add )
by David
08:20
created

Wordlift_Storage::get_first()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Storage: Storage Abstract Class.
4
 *
5
 * @since      3.15.0
6
 * @package    Wordlift
7
 * @subpackage Wordlift/includes/linked-data/storage
8
 */
9
10
/**
11
 * Define the {@link Wordlift_Storage} abstract class.
12
 *
13
 * @since      3.15.0
14
 * @package    Wordlift
15
 * @subpackage Wordlift/includes/linked-data/storage
16
 */
17
abstract class Wordlift_Storage {
18
19
	/**
20
	 * Get the values for the property of the {@link WP_Post}.
21
	 *
22
	 * @since 3.15.0
23
	 *
24
	 * @param int $post_id The {@link WP_Post}'s id.
25
	 *
26
	 * @return array
27
	 */
28
	abstract public function get( $post_id );
29
30
	/**
31
	 * Get the first value for a property.
32
	 *
33
	 * @since 3.15.0
34
	 *
35
	 * @param int $post_id The {@link WP_Post}'s id.
36
	 *
37
	 * @return string The first property value or an empty string.
38
	 */
39
	public function get_first( $post_id ) {
40
41
		$values = $this->get( $post_id );
42
43
		if ( empty( $values ) ) {
44
			return '';
45
		}
46
47
		return $values[0];
48
	}
49
50
}
51