Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| CountableIteratorAggregate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| getInnerIterator | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** |
| 6 | * This file is part of php-fast-forward/iterators. |
| 7 | * |
| 8 | * This source file is subject to the license that is bundled |
| 9 | * with this source code in the file LICENSE. |
| 10 | * |
| 11 | * @copyright Copyright (c) 2025-2026 Felipe Sayão Lobato Abreu <github@mentordosnerds.com> |
| 12 | * @license https://opensource.org/licenses/MIT MIT License |
| 13 | * |
| 14 | * @see https://github.com/php-fast-forward/iterators |
| 15 | * @see https://github.com/php-fast-forward |
| 16 | * @see https://datatracker.ietf.org/doc/html/rfc2119 |
| 17 | */ |
| 18 | |
| 19 | namespace FastForward\Iterator; |
| 20 | |
| 21 | use Countable; |
| 22 | use IteratorAggregate; |
| 23 | use Traversable; |
| 24 | |
| 25 | /** |
| 26 | * Provides a base implementation for iterator aggregate objects that are also countable. |
| 27 | * |
| 28 | * This abstract class SHALL serve as a reusable foundation for concrete iterator aggregate |
| 29 | * implementations that expose a traversable iterator and require count-related behavior. |
| 30 | * Implementations MUST provide a valid iterator through {@see getIterator()}, and that |
| 31 | * iterator SHOULD be suitable for reuse by the count-related logic provided through the |
| 32 | * composed trait. |
| 33 | */ |
| 34 | abstract class CountableIteratorAggregate implements IteratorAggregate, Countable |
| 35 | { |
| 36 | use CountableIteratorIteratorTrait; |
| 37 | |
| 38 | /** |
| 39 | * Returns the inner traversable iterator used by the aggregate. |
| 40 | * |
| 41 | * This method SHALL proxy the iterator returned by {@see getIterator()} without altering |
| 42 | * its semantics or traversal behavior. Consumers of this method MUST receive the same |
| 43 | * traversable instance or equivalent traversable representation exposed by the aggregate. |
| 44 | * This method SHOULD remain private because it exists only to support the internal |
| 45 | * collaboration between this class and its trait-based behavior. |
| 46 | * |
| 47 | * @return Traversable the traversable iterator exposed by the aggregate implementation |
| 48 | */ |
| 49 | private function getInnerIterator(): Traversable |
| 50 | { |
| 51 | return $this->getIterator(); |
| 52 | } |
| 53 | } |