Skip to content

Instantly share code, notes, and snippets.

@maks-rafalko
Created September 28, 2017 20:23
Show Gist options
  • Save maks-rafalko/b4c1b1d2c7c4bdad32ba707e41ed0b53 to your computer and use it in GitHub Desktop.
Save maks-rafalko/b4c1b1d2c7c4bdad32ba707e41ed0b53 to your computer and use it in GitHub Desktop.
Filter object
<?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