for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Nozavroni/Collections
* Just another collections library for PHP5.6+.
* @version {version}
* @copyright Copyright (c) 2016 Luke Visinoni <[email protected]>
* @author Luke Visinoni <[email protected]>
* @license https://github.com/deni-zen/csvelte/blob/master/LICENSE The MIT License (MIT)
*/
namespace Noz\Traits;
* Interface IsArrayable.
*
* Ensures a class can be converted to an array using toArray()
* @package Noz\Contracts
trait IsTraversable
{
* @var bool
protected $traversable = true;
* Is this object traversable?
* @return bool
public function isTraversable()
return $this->traversable;
}
* Traverse this object with given callback.
* Loops over this object, passing each iteration to callback function. Return false at any time from callback to exit loop and return false.
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.
* @param callable $callback
public function traverse(callable $callback)
if ($this->isTraversable()) {
foreach ($this as $key => $val) {
$this
this<Noz\Traits\IsTraversable>
if (!$callback($val, $key)) {
return false;
return true;
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.