Skip to content

Instantly share code, notes, and snippets.

@auxiliaire
Created April 7, 2021 19:40
Show Gist options
  • Select an option

  • Save auxiliaire/3d2b94df7572056c6f5f735a0826d291 to your computer and use it in GitHub Desktop.

Select an option

Save auxiliaire/3d2b94df7572056c6f5f735a0826d291 to your computer and use it in GitHub Desktop.
Implement `prop` in PHP
function prop(...$args) {
return self::curry(fn(string $prop, array $obj) => match (true) {
is_array($obj) && array_key_exists($prop, $obj) => $obj[$prop],
default => null
})(...$args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment