コード例 #1
0
ファイル: BitwiseEnum.php プロジェクト: dazarobbo/cola
 /**
  * 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);
 }
コード例 #2
0
 public function testFilter()
 {
     $arr = array(3, 2, 1);
     $arr = PHPArray::filter($arr, function ($item) {
         return $item % 2 === 0;
     });
     $this->assertCount(1, $arr);
 }
コード例 #3
0
ファイル: ArrayList.php プロジェクト: dazarobbo/cola
 /**
  * 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));
 }