示例#1
0
 public function test_partialRight_function_application()
 {
     $greeting = function ($greet, $name) {
         return "{$greet} {$name}";
     };
     $greetBrian = partialRight($greeting, 'Brian');
     $this->assertEquals('Hello! Brian', $greetBrian('Hello!'));
 }
示例#2
0
 public function test_compose_passes_results_from_end_to_first()
 {
     $makeCool = function ($name) {
         return $name . ' is cool.';
     };
     $subject = 'brian:scaturro';
     $findNameAndMakeItCool = compose($makeCool, 'ucfirst', partialRight('strstr', true, ':'));
     $result = $findNameAndMakeItCool($subject);
     $this->assertEquals('Brian is cool.', $result);
 }