ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CoreTestIterator Class Reference
+ Inheritance diagram for CoreTestIterator:
+ Collaboration diagram for CoreTestIterator:

Public Member Functions

 __construct (array $values, array $keys, $allowValueAccess=false, $maxPosition=false)
 
 rewind ()
 
 current ()
 
 key ()
 
 next ()
 
 valid ()
 

Private Attributes

 $position
 
 $array
 
 $arrayKeys
 
 $allowValueAccess
 
 $maxPosition
 

Detailed Description

Definition at line 307 of file CoreTest.php.

Constructor & Destructor Documentation

◆ __construct()

CoreTestIterator::__construct ( array  $values,
array  $keys,
  $allowValueAccess = false,
  $maxPosition = false 
)

Definition at line 315 of file CoreTest.php.

References $keys, and $values.

316  {
317  $this->array = $values;
318  $this->arrayKeys = $keys;
319  $this->position = 0;
320  $this->allowValueAccess = $allowValueAccess;
321  $this->maxPosition = false === $maxPosition ? count($values) + 1 : $maxPosition;
322  }
$keys
$values

Member Function Documentation

◆ current()

CoreTestIterator::current ( )

Definition at line 329 of file CoreTest.php.

330  {
331  if ($this->allowValueAccess) {
332  return $this->array[$this->key()];
333  }
334 
335  throw new LogicException('Code should only use the keys, not the values provided by iterator.');
336  }

◆ key()

CoreTestIterator::key ( )

Definition at line 338 of file CoreTest.php.

339  {
340  return $this->arrayKeys[$this->position];
341  }

◆ next()

CoreTestIterator::next ( )

Definition at line 343 of file CoreTest.php.

344  {
345  ++$this->position;
346  if ($this->position === $this->maxPosition) {
347  throw new LogicException(sprintf('Code should not iterate beyond %d.', $this->maxPosition));
348  }
349  }

◆ rewind()

CoreTestIterator::rewind ( )

Definition at line 324 of file CoreTest.php.

325  {
326  $this->position = 0;
327  }

◆ valid()

CoreTestIterator::valid ( )

Definition at line 351 of file CoreTest.php.

352  {
353  return isset($this->arrayKeys[$this->position]);
354  }

Field Documentation

◆ $allowValueAccess

CoreTestIterator::$allowValueAccess
private

Definition at line 312 of file CoreTest.php.

◆ $array

CoreTestIterator::$array
private

Definition at line 310 of file CoreTest.php.

◆ $arrayKeys

CoreTestIterator::$arrayKeys
private

Definition at line 311 of file CoreTest.php.

◆ $maxPosition

CoreTestIterator::$maxPosition
private

Definition at line 313 of file CoreTest.php.

◆ $position

CoreTestIterator::$position
private

Definition at line 309 of file CoreTest.php.


The documentation for this class was generated from the following file: