wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/Iterator/IteratorDecorator.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace CirrusSearch\Iterator;

use Iterator;

/**
 * Allows extending classes to decorate an Iterator with
 * reduced boilerplate.
 */
abstract class IteratorDecorator implements Iterator {
    protected Iterator $iterator;

    public function __construct( Iterator $iterator ) {
        $this->iterator = $iterator;
    }

    #[\ReturnTypeWillChange]
    public function current() {
        return $this->iterator->current();
    }

    #[\ReturnTypeWillChange]
    public function key() {
        return $this->iterator->key();
    }

    public function next(): void {
        $this->iterator->next();
    }

    public function rewind(): void {
        $this->iterator->rewind();
    }

    public function valid(): bool {
        return $this->iterator->valid();
    }
}