| 148 |
lars |
1 |
<?php declare(strict_types = 1);
|
|
|
2 |
/*
|
|
|
3 |
* This file is part of PharIo\Manifest.
|
|
|
4 |
*
|
|
|
5 |
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, 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 PharIo\Manifest;
|
|
|
11 |
|
|
|
12 |
class RequirementCollectionIterator implements \Iterator {
|
|
|
13 |
/** @var Requirement[] */
|
|
|
14 |
private $requirements;
|
|
|
15 |
|
|
|
16 |
/** @var int */
|
|
|
17 |
private $position = 0;
|
|
|
18 |
|
|
|
19 |
public function __construct(RequirementCollection $requirements) {
|
|
|
20 |
$this->requirements = $requirements->getRequirements();
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
public function rewind(): void {
|
|
|
24 |
$this->position = 0;
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public function valid(): bool {
|
|
|
28 |
return $this->position < \count($this->requirements);
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
public function key(): int {
|
|
|
32 |
return $this->position;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
public function current(): Requirement {
|
|
|
36 |
return $this->requirements[$this->position];
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
public function next(): void {
|
|
|
40 |
$this->position++;
|
|
|
41 |
}
|
|
|
42 |
}
|