Пример #1
0
 /**
  * @test
  */
 public function shouldChainFunctionCalls()
 {
     //given
     $function = FluentFunctions::extractField('name')->removePrefix('super')->prepend(' extra')->append('! ')->surroundWith("***");
     //when
     $result = Functions::call($function, new Product(array('name' => 'super phone')));
     //then
     $this->assertEquals('*** extra phone! ***', $result);
 }
Пример #2
0
 /**
  * @test
  */
 public function shouldReturnOrForAbsentMap()
 {
     //given
     $optional = Optional::fromNullable(null);
     $closure = FluentFunctions::extractField('myField')->append('!!!');
     //when
     $result = $optional->map($closure)->or('def');
     //then
     $this->assertEquals('def', $result);
 }