ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
InfoCollection.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Countable;
24use Iterator;
25
26class InfoCollection implements Countable, Iterator
27{
28 protected int $index;
29 protected array $elements;
30
31 public function __construct()
32 {
33 $this->index = 0;
34 $this->elements = [];
35 }
36
37 public function current(): Info
38 {
39 return $this->elements[$this->index];
40 }
41
42 public function next(): void
43 {
44 $this->index++;
45 }
46
47 public function key(): int
48 {
49 return $this->index;
50 }
51
52 public function valid(): bool
53 {
54 return isset($this->elements[$this->index]);
55 }
56
57 public function rewind(): void
58 {
59 $this->index = 0;
60 }
61
62 public function count(): int
63 {
64 return count($this->elements);
65 }
66
67 public function withInfo(
70 $clone = clone $this;
71 $clone->elements[] = $info;
72 return $clone;
73 }
74}
$info
Definition: entry_point.php:21