[$result, $exception] = attempt(function() {
throw new \Exception('hello exception');
});
if ($exception){
// Do something with exception
}
OR if you don't care about exception, you can use it like below:
[$result] = attempt(function() {
return 3;
});