← All changes
|
jetpack_vendor/automattic/jetpack-sync/src/class-utils.php
+65
-0
16.2-beta
→
16.3
View file →
| @@ -1,0 +1,65 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Sync utils. | |
| 4 | + * | |
| 5 | + * @package automattic/jetpack-sync | |
| 6 | + */ | |
| 7 | + | |
| 8 | +namespace Automattic\Jetpack\Sync; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * Class for sync utilities. | |
| 12 | + */ | |
| 13 | +class Utils { | |
| 14 | + /** | |
| 15 | + * Retrieve the values of sync items. | |
| 16 | + * | |
| 17 | + * @access public | |
| 18 | + * @static | |
| 19 | + * | |
| 20 | + * @param array $items Array of sync items. | |
| 21 | + * @return array Array of sync item values. | |
| 22 | + */ | |
| 23 | + public static function get_item_values( $items ) { | |
| 24 | + return array_map( array( __CLASS__, 'get_item_value' ), $items ); | |
| 25 | + } | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * Retrieve the IDs of sync items. | |
| 29 | + * | |
| 30 | + * @access public | |
| 31 | + * @static | |
| 32 | + * | |
| 33 | + * @param array $items Array of sync items. | |
| 34 | + * @return array Array of sync item IDs. | |
| 35 | + */ | |
| 36 | + public static function get_item_ids( $items ) { | |
| 37 | + return array_map( array( __CLASS__, 'get_item_id' ), $items ); | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * Get the value of a sync item. | |
| 42 | + * | |
| 43 | + * @access private | |
| 44 | + * @static | |
| 45 | + * | |
| 46 | + * @param array $item Sync item. | |
| 47 | + * @return mixed Sync item value. | |
| 48 | + */ | |
| 49 | + private static function get_item_value( $item ) { | |
| 50 | + return $item->value; | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * Get the ID of a sync item. | |
| 55 | + * | |
| 56 | + * @access private | |
| 57 | + * @static | |
| 58 | + * | |
| 59 | + * @param array $item Sync item. | |
| 60 | + * @return int Sync item ID. | |
| 61 | + */ | |
| 62 | + private static function get_item_id( $item ) { | |
| 63 | + return $item->id; | |
| 64 | + } | |
| 65 | +} | |