Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| service_collection_iterator | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| current | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | namespace phpbb\di; |
| 15 | |
| 16 | /** |
| 17 | * Iterator which loads the services when they are requested |
| 18 | */ |
| 19 | class service_collection_iterator extends \ArrayIterator |
| 20 | { |
| 21 | /** |
| 22 | * @var \phpbb\di\service_collection |
| 23 | */ |
| 24 | protected $collection; |
| 25 | |
| 26 | /** |
| 27 | * Construct an ArrayIterator for service_collection |
| 28 | * |
| 29 | * @param \phpbb\di\service_collection $collection The collection to iterate over |
| 30 | * @param int $flags Flags to control the behaviour of the ArrayObject object. |
| 31 | * @see ArrayObject::setFlags() |
| 32 | */ |
| 33 | public function __construct(service_collection $collection, $flags = 0) |
| 34 | { |
| 35 | parent::__construct($collection->getArrayCopy(), $flags); |
| 36 | $this->collection = $collection; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * {@inheritdoc} |
| 41 | */ |
| 42 | public function current(): mixed |
| 43 | { |
| 44 | return $this->collection->offsetGet($this->key()); |
| 45 | } |
| 46 | } |