Skip to content

Instantly share code, notes, and snippets.

@temp
Last active May 10, 2019 18:27
Show Gist options
  • Select an option

  • Save temp/d52aeaa3009c42765d67a829dd7ee9fb to your computer and use it in GitHub Desktop.

Select an option

Save temp/d52aeaa3009c42765d67a829dd7ee9fb to your computer and use it in GitHub Desktop.
<?php
function arr($config): callable {
return static function ($value) use ($config) {
return map(static function($f) use ($value) {
return $f($value);
}, $config);
};
}
$fn = converge(
merge(),
[
arr([
'contact' => arr([
'id' => prop('contact_id'),
'name' => prop('contact_name'),
]),
'unloadingPoint' => ifElse(
compose(isEmpty(), prop('unloading_point_code')),
null,
arr([
'id' => prop('unloading_point_code'),
'value' => prop('unloading_point_description'),
]),
),
'creationDate' => converge(
join(' '),
[
pipe(prop('creation_date_date'), take(10)),
pipe(prop('creation_date_time'), drop(11), take(8)),
]
),
]),
omit([
'contact_id', 'contact_name',
'unloading_point_code', 'unloading_point_description',
'creation_date_date', 'creation_date_time',
]),
]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment