Esempio n. 1
0
 public function testHasPrecurriedVersion()
 {
     $join = function ($a, $b) {
         return "{$a} {$b}";
     };
     $data = ['name' => ['first' => 'James', 'last' => 'Bond'], 'code' => '007', 'country' => 'UK'];
     $this->assertSame('James Bond 007', call_user_func(call_user_func(F\C1\converge($join), [F\compose(F\curry('implode', ' '), 'array_values', F\C2\propOr('', 'name')), F\C2\propOr('', 'code')]), $data));
 }
Esempio n. 2
0
 public function testHasPrecurriedVersionWithAnArityOfTwo()
 {
     $this->assertSame(4, call_user_func(F\C2\propOr(1, 'goo'), ['goo' => 4]));
 }
Esempio n. 3
0
 public function testWorks()
 {
     $this->assertEquals(['abc' => ['id' => 'abc', 'title' => 'B'], 'xyz' => ['id' => 'xyz', 'title' => 'A']], F\indexBy(F\C2\propOr('', 'id'), [['id' => 'xyz', 'title' => 'A'], ['id' => 'abc', 'title' => 'B']]));
 }