ILIAS  release_8 Revision v8.24
class.ilCtrlArrayIterator.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 2021 Thibeau Fuhrer <thf@studer-raimann.ch> Extended GPL, see docs/LICENSE */
6
13{
17 private array $data;
18
24 public function __construct(array $data)
25 {
26 $this->data = $data;
27 }
28
32 public function current(): ?string
33 {
34 if ($this->valid()) {
35 return current($this->data);
36 }
37
38 return null;
39 }
40
44 public function next(): void
45 {
46 next($this->data);
47 }
48
52 public function key(): ?string
53 {
54 if ($this->valid()) {
55 return key($this->data);
56 }
57
58 return null;
59 }
60
64 public function valid(): bool
65 {
66 $value = current($this->data);
67 $key = key($this->data);
68
69 if (null === $key) {
70 return false;
71 }
72
73 if (!is_string($value) || !is_string($key)) {
74 $this->next();
75 return $this->valid();
76 }
77
78 return true;
79 }
80
84 public function rewind(): void
85 {
86 reset($this->data);
87 }
88}
Class ilCtrlArrayIterator.
__construct(array $data)
ilCtrlArrayIterator Constructor
Interface ilCtrlIteratorInterface.
string $key
Consumer key/client ID value.
Definition: System.php:193