Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
RegexPartIterator
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
6 / 6
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 current
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 key
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 next
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 rewind
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 valid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2namespace Apie\RegexTools;
3
4use Apie\RegexTools\Parts\RegexPartInterface;
5use Iterator;
6
7final class RegexPartIterator implements Iterator
8{
9    private int $counter = 0;
10
11    private ?RegexPartInterface $currentPart = null;
12
13    private ?RegexStream $stream = null;
14
15    public function __construct(private readonly string $input)
16    {
17    }
18
19    public function current(): ?RegexPartInterface
20    {
21        return $this->currentPart;
22    }
23    public function key(): int
24    {
25        return $this->counter;
26    }
27    public function next(): void
28    {
29        $this->counter++;
30        $this->currentPart = $this->stream->nextToken();
31    }
32    public function rewind(): void
33    {
34        $this->counter = 0;
35        $this->stream = new RegexStream($this->input);
36        $this->currentPart = $this->stream->nextToken();
37    }
38    public function valid(): bool
39    {
40        return null !== $this->stream && null !== $this->currentPart;
41    }
42}