Completed
Pull Request — develop (#1321)
by
unknown
02:53
created

Wordlift_Required_Property_Service::get()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 2
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Process required references returning a {@link Wordlift_Property_Entity_Reference}
4
 *
5
 * @since 3.29.1
6
 */
7
class Wordlift_Required_Property_Service extends Wordlift_Entity_Property_Service {
8
9
	/**
10
	 * {@inheritdoc}
11
	 */
12
	public function get( $post_id, $meta_key ) {
13
14
		return array_map( function ( $item ) {
15
16
			// If this is an entity reference, set that this entity is always required in SD output.
17
			if ( $item instanceof Wordlift_Property_Entity_Reference ) {
18
				$item->set_required( true );
19
			}
20
21
			return $item;
22
		}, parent::get( $post_id, $meta_key ) );
23
	}
24
25
}
26