ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilCtrlArrayIterator.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
31  private array $data;
32 
38  public function __construct(array $data)
39  {
40  $this->data = $data;
41  }
42 
46  public function current(): ?string
47  {
48  if ($this->valid()) {
49  return current($this->data);
50  }
51 
52  return null;
53  }
54 
58  public function next(): void
59  {
60  next($this->data);
61  }
62 
66  public function key(): ?string
67  {
68  if ($this->valid()) {
69  return key($this->data);
70  }
71 
72  return null;
73  }
74 
78  public function valid(): bool
79  {
80  $value = current($this->data);
81  $key = key($this->data);
82 
83  if (null === $key) {
84  return false;
85  }
86 
87  if (!is_string($value) || !is_string($key)) {
88  $this->next();
89  return $this->valid();
90  }
91 
92  return true;
93  }
94 
98  public function rewind(): void
99  {
100  reset($this->data);
101  }
102 }
__construct(array $data)
ilCtrlArrayIterator Constructor
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrlArrayIterator.