Last active
May 10, 2019 18:27
-
-
Save temp/d52aeaa3009c42765d67a829dd7ee9fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| 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