Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
Queue_Buffer
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 4
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 get_items
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_item_values
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_item_ids
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Sync queue buffer.
4 *
5 * @package automattic/jetpack-sync
6 */
7
8namespace Automattic\Jetpack\Sync;
9
10/**
11 * A buffer of items from the queue that can be checked out.
12 */
13class Queue_Buffer {
14    /**
15     * Sync queue buffer ID.
16     *
17     * @access public
18     *
19     * @var int
20     */
21    public $id;
22
23    /**
24     * Sync items.
25     *
26     * @access public
27     *
28     * @var array
29     */
30    public $items_with_ids;
31
32    /**
33     * Constructor.
34     * Initializes the queue buffer.
35     *
36     * @access public
37     *
38     * @param int   $id             Sync queue buffer ID.
39     * @param array $items_with_ids Items for the buffer to work with.
40     */
41    public function __construct( $id, $items_with_ids ) {
42        $this->id             = $id;
43        $this->items_with_ids = $items_with_ids;
44    }
45
46    /**
47     * Retrieve the sync items in the buffer, in an ID => value form.
48     *
49     * @access public
50     *
51     * @return bool|array Sync items in the buffer.
52     */
53    public function get_items() {
54        return array_combine( $this->get_item_ids(), $this->get_item_values() );
55    }
56
57    /**
58     * Retrieve the values of the sync items in the buffer.
59     *
60     * @access public
61     *
62     * @return array Sync items values.
63     */
64    public function get_item_values() {
65        return Utils::get_item_values( $this->items_with_ids );
66    }
67
68    /**
69     * Retrieve the IDs of the sync items in the buffer.
70     *
71     * @access public
72     *
73     * @return array Sync items IDs.
74     */
75    public function get_item_ids() {
76        return Utils::get_item_ids( $this->items_with_ids );
77    }
78}