for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* File IterableTrait.php
*
* @author Edward Pfremmer <[email protected]>
*/
namespace Epfremme\Collection\Traits;
* Trait IterableTrait
* @property array|mixed[] $elements
* @package Epfremme\Collection\Traits
trait IterableTrait
{
* Return the current element
* @return mixed
public function current()
return current($this->elements);
}
* Return the fist element
public function first()
return reset($this->elements);
* Advance and return last element
public function last()
return end($this->elements);
* Move elements pointer forward
public function next()
return next($this->elements);
* Move elements pointer backward
* @reutrn void
public function prev()
return prev($this->elements);
* Return the key of the current element
public function key()
return key($this->elements);
* Checks if current position is valid
* @return bool
public function valid()
return key($this->elements) !== null;
* Reset pointer and return the first element
public function reset()
* Rewind the collection pointer
* @return void
public function rewind()
$this->reset();