Created
September 28, 2017 20:23
-
-
Save maks-rafalko/b4c1b1d2c7c4bdad32ba707e41ed0b53 to your computer and use it in GitHub Desktop.
Filter object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class UserFilterAge | |
{ | |
const AGE_THRESHOLD = 18; | |
public function __invoke(array $collection) | |
{ | |
return array_filter( | |
$collection, | |
function (array $item) { | |
return $item['age'] >= self::AGE_THRESHOLD; | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment