public function testCompose() { // from js $greet = function ($name) { return 'hi: ' . $name; }; $exclaim = function ($sentence) { return $sentence . '!'; }; $composed = __u::compose($exclaim, $greet); $this->assertEquals('hi: moe!', $composed('moe'), 'can compose a function that takes another'); $composed = __u::compose($greet, $exclaim); $this->assertEquals('hi: moe!', $composed('moe'), 'in this case, the functions are also commutative'); // extra $composed = __u($greet)->compose($exclaim); $this->assertEquals('hi: moe!', $composed('moe'), 'in this case, the functions are also commutative'); // docs $greet = function ($name) { return 'hi: ' . $name; }; $exclaim = function ($statement) { return $statement . '!'; }; $welcome = __u::compose($exclaim, $greet); $this->assertEquals('hi: moe!', $welcome('moe')); }