Beispiel #1
0
 /**
  * @test
  */
 public function prop()
 {
     $name = F\prop('name');
     $this->assertEquals($name(['name' => 'Jack']), 'Jack');
     $this->assertFalse($name([]));
     $this->assertEquals(F\prop('name', ['name' => 'Jack']), 'Jack');
 }
Beispiel #2
0
 /**
  * @test
  */
 public function ifelse()
 {
     $ls = ['name' => 'James Tiberius Kirk'];
     $upper = F\compose('strtoupper', F\prop('name'));
     $expected = F\ifelse(F\has('name'), $upper, F\always(false));
     $this->assertEquals($expected($ls), 'JAMES TIBERIUS KIRK');
     $expected = F\ifelse(F\has('lastname'), $upper, F\always(false));
     $this->assertFalse($expected($ls));
 }