summaryrefslogtreecommitdiff
blob: 23f24e95d36a26e04ef0504fb2a6fae5d6bbb164 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
 * Sync utils.
 *
 * @package automattic/jetpack-sync
 */

namespace Automattic\Jetpack\Sync;

/**
 * Class for sync utilities.
 */
class Utils {
	/**
	 * Retrieve the values of sync items.
	 *
	 * @access public
	 * @static
	 *
	 * @param array $items Array of sync items.
	 * @return array Array of sync item values.
	 */
	public static function get_item_values( $items ) {
		return array_map( array( __CLASS__, 'get_item_value' ), $items );
	}

	/**
	 * Retrieve the IDs of sync items.
	 *
	 * @access public
	 * @static
	 *
	 * @param array $items Array of sync items.
	 * @return array Array of sync item IDs.
	 */
	public static function get_item_ids( $items ) {
		return array_map( array( __CLASS__, 'get_item_id' ), $items );
	}

	/**
	 * Get the value of a sync item.
	 *
	 * @access private
	 * @static
	 *
	 * @param array $item Sync item.
	 * @return mixed Sync item value.
	 */
	private static function get_item_value( $item ) {
		return $item->value;
	}

	/**
	 * Get the ID of a sync item.
	 *
	 * @access private
	 * @static
	 *
	 * @param array $item Sync item.
	 * @return int Sync item ID.
	 */
	private static function get_item_id( $item ) {
		return $item->id;
	}
}