Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
3 / 3
ItemCollection
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
3 / 3
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 jsonSerialize
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
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 - 2021  Timothy J. Warren
12 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13 * @version     5.0.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 */
29class ItemCollection extends ArrayIterator implements JsonSerializable {
30
31    /**
32     * The raw CacheItemInterface objects
33     *
34     * @var CacheItemInterface[]
35     */
36    protected array $items = [];
37
38    /**
39     * Create the collection object from the raw
40     * CacheItemInterface array
41     *
42     * @param array $items - array of CacheItemInterface objects
43     * @param int $flags - flags
44     */
45    public function __construct(array $items = [], $flags = 0)
46    {
47        parent::__construct($items, $flags);
48        $this->items = $items;
49    }
50
51    /**
52     * Specify what data to serialize when using `json_encode`
53     *
54     * @return array - The full set of data to be serialized
55     */
56    public function jsonSerialize(): array
57    {
58        return $this->items;
59    }
60}