blob: a9846150cc1e711a54451668b24e29619840243a (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
|
<?php
/**
* Sync queue buffer.
*
* @package automattic/jetpack-sync
*/
namespace Automattic\Jetpack\Sync;
/**
* A buffer of items from the queue that can be checked out.
*/
class Queue_Buffer {
/**
* Sync queue buffer ID.
*
* @access public
*
* @var int
*/
public $id;
/**
* Sync items.
*
* @access public
*
* @var array
*/
public $items_with_ids;
/**
* Constructor.
* Initializes the queue buffer.
*
* @access public
*
* @param int $id Sync queue buffer ID.
* @param array $items_with_ids Items for the buffer to work with.
*/
public function __construct( $id, $items_with_ids ) {
$this->id = $id;
$this->items_with_ids = $items_with_ids;
}
/**
* Retrieve the sync items in the buffer, in an ID => value form.
*
* @access public
*
* @return array Sync items in the buffer.
*/
public function get_items() {
return array_combine( $this->get_item_ids(), $this->get_item_values() );
}
/**
* Retrieve the values of the sync items in the buffer.
*
* @access public
*
* @return array Sync items values.
*/
public function get_item_values() {
return Utils::get_item_values( $this->items_with_ids );
}
/**
* Retrieve the IDs of the sync items in the buffer.
*
* @access public
*
* @return array Sync items IDs.
*/
public function get_item_ids() {
return Utils::get_item_ids( $this->items_with_ids );
}
}
|