Skip to content

Instantly share code, notes, and snippets.

@ihabunek
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihabunek/ec715448fb86813d3917 to your computer and use it in GitHub Desktop.
Save ihabunek/ec715448fb86813d3917 to your computer and use it in GitHub Desktop.
How functional programming affected my use of PHP
// Before FP
$listings = [];
foreach ($docs as $item) {
$listings[] = Listing::fromSolr($item);
}
// After FP
$listings = array_map([Listing::class, 'fromSolr'], $docs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment