Completed
Push — master ( 37bdb3...5c343e )
by David
03:17 queued 10s
created

Wordlift_Duration_Property_Service::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Properties: Duration Property.
4
 *
5
 * This file is part of the properties group of files which handle the duration
6
 * property of entities.
7
 *
8
 * @since      3.14.0
9
 * @package    Wordlift
10
 * @subpackage Wordlift/includes/properties
11
 */
12
13
/**
14
 * Process references to time durations, convert them into proper  ISO 8601 duration format.
15
 *
16
 * @since      3.14.0
17
 * @package    Wordlift
18
 * @subpackage Wordlift/includes/properties
19
 */
20
class Wordlift_Duration_Property_Service extends Wordlift_Simple_Property_Service {
21
22
	/**
23
	 * {@inheritdoc}
24
	 */
25
	function get( $post_id, $meta_key ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
26
27
		/*
28
		 * Map the value in the meta
29
		 * The UI for the meta date enable two forms, a number of minutes
30
		 * or an h:mm format.
31
		 * Both needs to be adjusted to the iso format.
32
		 */
33
		return array_map( function ( $value ) {
34
			return 'PT' . str_replace( ':', 'H', $value ) . 'M';
35
		}, parent::get( $post_id, $meta_key ) );
36
	}
37
38
}
39