Completed
Push — develop ( 811f38...1e789a )
by Paul
04:11
created

PostMeta   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 21 4
1
<?php
2
3
namespace GeminiLabs\Castor\Helpers;
4
5
class PostMeta
6
{
7
	public function get( $value, array $args = [] )
8
	{
9
		$defaults = [
10
			'ID'       => get_the_ID(),
11
			'fallback' => '',
12
			'single'   => true,
13
			'prefix'   => 'pollux_',
14
		];
15
16
		$args = shortcode_atts( $defaults, $args );
17
18
		if( $value[0] == '_' && !empty( $args['prefix'] )) {
19
			$args['prefix'] = sprintf( '_%s', rtrim( $args['prefix'], '_' ));
20
		}
21
22
		$metaValue = get_post_meta( $args['ID'], $args['prefix'] . $value, $args['single'] );
23
24
		return empty( $metaValue )
25
			? $args['fallback']
26
			: $metaValue;
27
	}
28
}
29