File tree Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -436,18 +436,30 @@ public function transform($callback)
436
436
*
437
437
* @since 3.1.3
438
438
*/
439
- public function filter ($ callback )
439
+ public function filter ($ callback = null )
440
440
{
441
441
$ dataset = clone $ this ;
442
442
443
- $ dataset ->data = array_filter ($ dataset ->data , $ callback , ARRAY_FILTER_USE_BOTH );
443
+ if (!$ callback )
444
+ {
445
+ $ dataset ->data = array_filter ($ dataset ->data );
444
446
445
- return $ dataset ;
446
- }
447
+ return $ dataset ;
448
+ }
447
449
448
- public function reject ($ callback )
449
- {
450
+ $ return = array ();
450
451
452
+ foreach ($ dataset ->data as $ key => $ value )
453
+ {
454
+ if (call_user_func ($ callback , $ value , $ key ))
455
+ {
456
+ $ return [$ key ] = $ value ;
457
+ }
458
+ }
459
+
460
+ $ dataset ->data = $ return ;
461
+
462
+ return $ dataset ;
451
463
}
452
464
453
465
/**
Original file line number Diff line number Diff line change @@ -178,6 +178,13 @@ public function testMutator()
178
178
*/
179
179
public function testJsonSerialize ()
180
180
{
181
+ if (version_compare (PHP_VERSION , '5.4 ' , '< ' ))
182
+ {
183
+ $ this ->markTestSkipped ('PHP 5.3 do not support JsonSerialize() ' );
184
+
185
+ return ;
186
+ }
187
+
181
188
$ this ->assertEquals (json_encode ($ this ->instance ->dump (true )), json_encode ($ this ->instance ));
182
189
}
183
190
}
You can’t perform that action at this time.
0 commit comments