Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of sebastian/code-unit.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SebastianBergmann\CodeUnit;
11
 
12
use Iterator;
13
 
14
final class CodeUnitCollectionIterator implements Iterator
15
{
16
    /**
17
     * @psalm-var list<CodeUnit>
18
     */
19
    private $codeUnits;
20
 
21
    /**
22
     * @var int
23
     */
24
    private $position = 0;
25
 
26
    public function __construct(CodeUnitCollection $collection)
27
    {
28
        $this->codeUnits = $collection->asArray();
29
    }
30
 
31
    public function rewind(): void
32
    {
33
        $this->position = 0;
34
    }
35
 
36
    public function valid(): bool
37
    {
38
        return isset($this->codeUnits[$this->position]);
39
    }
40
 
41
    public function key(): int
42
    {
43
        return $this->position;
44
    }
45
 
46
    public function current(): CodeUnit
47
    {
48
        return $this->codeUnits[$this->position];
49
    }
50
 
51
    public function next(): void
52
    {
53
        $this->position++;
54
    }
55
}