-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathVector.php
46 lines (36 loc) · 789 Bytes
/
Vector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Dunglas\DoctrineJsonOdm\Tests\Fixtures\TestBundle\Document;
class Vector implements \Iterator
{
private int $position;
private array $array;
public function __construct(array $array = null)
{
$this->array = $array ?? [];
$this->position = 0;
}
public function getArray(): array
{
return $this->array;
}
public function current(): mixed
{
return $this->array[$this->key()];
}
public function key(): mixed
{
return $this->position;
}
public function next(): void
{
++$this->position;
}
public function rewind(): void
{
$this->position = 0;
}
public function valid(): bool
{
return isset($this->array[$this->key()]);
}
}