/** * Returns an array of this class' constant names which are defined * in this instance * @return string[] */ public function getNames() { $isSet = PHPArray::filter(static::getConstants(), function ($value) { return $this->hasFlag($value); }); return \array_keys($isSet); }
public function testFilter() { $arr = array(3, 2, 1); $arr = PHPArray::filter($arr, function ($item) { return $item % 2 === 0; }); $this->assertCount(1, $arr); }
/** * Returns a new list with only those items passing a given predicate * @param \Closure $predicate * @return \static */ public function filter(\Closure $predicate) { return new static(PHPArray::filter($this->_Arr, $predicate)); }