Skip to content

Commit

Permalink
Fix php version issue
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Nov 19, 2016
1 parent 6bdcfad commit c13f6bf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/Data/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,18 +436,30 @@ public function transform($callback)
*
* @since 3.1.3
*/
public function filter($callback)
public function filter($callback = null)
{
$dataset = clone $this;

$dataset->data = array_filter($dataset->data, $callback, ARRAY_FILTER_USE_BOTH);
if (!$callback)
{
$dataset->data = array_filter($dataset->data);

return $dataset;
}
return $dataset;
}

public function reject($callback)
{
$return = array();

foreach ($dataset->data as $key => $value)
{
if (call_user_func($callback, $value, $key))
{
$return[$key] = $value;
}
}

$dataset->data = $return;

return $dataset;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/DataMapper/Test/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ public function testMutator()
*/
public function testJsonSerialize()
{
if (version_compare(PHP_VERSION, '5.4', '<'))
{
$this->markTestSkipped('PHP 5.3 do not support JsonSerialize()');

return;
}

$this->assertEquals(json_encode($this->instance->dump(true)), json_encode($this->instance));
}
}

0 comments on commit c13f6bf

Please sign in to comment.