Esempio n. 1
0
 public function testIFilterIndexNotExistsNotFiltered()
 {
     $list = ['a' => ['h' => 'o', 'i' => 'p', 'j' => 'q'], 'b' => ['h' => 'o', 'i' => '', 'j' => 'q']];
     $actual = Arrays::ifilter($list, 'NoneExisting', true);
     $expected = ['a' => ['h' => 'o', 'i' => 'p', 'j' => 'q'], 'b' => ['h' => 'o', 'i' => '', 'j' => 'q']];
     $this->assertEquals($expected, $actual);
 }
Esempio n. 2
0
 /**
  * Filter a list of arrays by removing the ones with an empty() value for some
  * index. This function works just like @{function:mfilter}, except that it
  * operates on a list of arrays instead of a list of objects.
  *
  * For example, to remove all arrays without value for key 'username', do this:
  *
  *   ifilter($list, 'username');
  *
  * The optional third parameter allows you to negate the operation and filter
  * out nonempty arrays. To remove all arrays that DO have value for key
  * 'username', do this:
  *
  *   ifilter($list, 'username', true);
  *
  * @param  $list        array        List of arrays to filter.
  * @param  $index       mixed       The index.
  * @param  $negate      bool         Optionally, pass true to drop arrays
  *                      which pass the filter instead of keeping them.
  *
  * @return array   List of arrays which pass the filter.
  * @throws InvalidArgumentException
  * @group  util
  *
  * @deprecated
  */
 function ifilter(array $list, $index, $negate = false)
 {
     return \Packaged\Helpers\Arrays::ifilter($list, $index, $negate);
 }