Completed
Push — master ( 228e92...6a576a )
by David
02:49
created

Wordlift_Simple_Property_Service::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 12 and the first side effect is on line 4.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
// Require the Wordlift_Property_Not_Found class.
4
require_once( "class-wordlift-property-not-found.php" );
5
require_once( "class-wordlift-property-entity-reference.php" );
6
7
/**
8
 * A property service that just returns the value stored in WP's meta.
9
 *
10
 * @since 3.8.0
11
 */
12
class Wordlift_Simple_Property_Service {
13
14
	/**
15
	 * The meta key for this property service.
16
	 *
17
	 * @since 3.8.0
18
	 */
19
	const META_KEY = '*';
20
21
	/**
22
	 * Get the property value for the specified post id and meta with the specified key.
23
	 *
24
	 * @since 3.8.0
25
	 *
26
	 * @param int $post_id The post id.
27
	 * @param string $meta_key The meta key.
28
	 *
29
	 * @return mixed|null The property value.
30
	 */
31
	public function get( $post_id, $meta_key ) {
32
33
		// Get the value stored in WP.
34
		return get_post_meta( $post_id, $meta_key );
35
	}
36
37
}
38