- array_map: documentation ( source)
- var_dump: documentation ( source)
- htmlentities: documentation ( source)
- array_filter: documentation ( source)
- strtoupper: documentation ( source)
- str_split: documentation ( source)
<?php
declare(strict_types=1);
$processor = compose(
htmlentities(...),
str_split(...),
fn ($x) => array_map(strtoupper(...), $x),
fn ($x) => array_filter($x, fn ($v) => $v != 'O'),
);
$data = "Hello World!";
var_dump(
$data,
$processor($data),
);
// polyfill
function compose(...$calls): Closure
{
$next = fn ($data) => $data;
foreach ($calls as $prev) {
$next = fn ($data) => $prev($next($data));
}
return $next;
}