Exemplo n.º 1
0
 /**
  * @test
  */
 public function it_returns_Failure_if_the_callable_thrown()
 {
     $failure = Attempt::call(function () {
         throw new Exception();
     });
     $this->assertInstanceOf('PhpTry\\Failure', $failure);
 }
Exemplo n.º 2
0
function promptDivide()
{
    $a = prompt("Enter a number (a) that you'd like to divide:");
    $b = prompt("Enter a number (b) that you'd like to divide by:");
    $c = prompt("Enter a number (c) that you'd like to multiply by:");
    return Attempt::call('divide', array($a, $b))->map(function ($elem) use($c) {
        return multiply($elem, $c);
    });
}
Exemplo n.º 3
0
 public function map($callable)
 {
     return Attempt::call($callable, array($this->value));
 }
Exemplo n.º 4
0
 public function recover($callable)
 {
     return Attempt::call($callable, array($this->exception));
 }