Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ItemCollection
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php declare(strict_types=1);
2/**
3 * Banker
4 *
5 * A Caching library implementing psr/cache (PSR 6) and psr/simple-cache (PSR 16)
6 *
7 * PHP version 8+
8 *
9 * @package     Banker
10 * @author      Timothy J. Warren <tim@timshomepage.net>
11 * @copyright   2016 - 2023  Timothy J. Warren
12 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13 * @version     4.1.0
14 * @link        https://git.timshomepage.net/timw4mail/banker
15 */
16namespace Aviat\Banker;
17
18use Psr\Cache\CacheItemInterface;
19
20use ArrayIterator;
21use JsonSerializable;
22
23/**
24 * Collection of Psr\Cache\CacheItemInterface objects to be returned by getItems
25 *
26 * @see http://php.net/manual/en/class.arrayiterator.php
27 * @see http://php.net/manual/en/class.jsonserializable.php
28 * @extends ArrayIterator<string, CacheItemInterface>
29 */
30class ItemCollection extends ArrayIterator implements JsonSerializable {
31
32    /**
33     * The raw CacheItemInterface objects
34     *
35     * @var CacheItemInterface[]
36     */
37    protected array $items = [];
38
39    /**
40     * Create the collection object from the raw
41     * CacheItemInterface array
42     *
43     * @param CacheItemInterface[] $items - array of CacheItemInterface objects
44     * @param int $flags - flags
45     */
46    public function __construct(array $items = [], int $flags = 0)
47    {
48        parent::__construct($items, $flags);
49        $this->items = $items;
50    }
51
52    /**
53     * Specify what data to serialize when using `json_encode`
54     *
55     * @return CacheItemInterface[] - The full set of data to be serialized
56     */
57    public function jsonSerialize(): array
58    {
59        return $this->items;
60    }
61}