
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 0.54 KB | hits: 9 | expires: Never
<?php
class AdWizard
{
protected $steps = array();
// ...
/**
* How to find a step with an identifier provided using array_filter function
*/
public function step($identifier)
{
list($step) = \array_filter($this->steps, function($step) use ($identifier) {
return $step->getIdentifier() == $identifier;
});
if (false == $step)) {
throw new \InvalidArgumentException('The step with identifier `'.$identifier.'` was not found');
}
return $step;
}
}