Just remove return and do:
$result = function () use ($that) { if (!in_array($currencyType, $this->ratio)) return false; return ($this->ratio[$currencyType] * $this->money); //a float number }; return $result();
Also, do you realize that you are not using $that inside a function?
By the way, why do I need an anonymous function? Just do:
function convert($currencyType) { if (!in_array($currencyType, $this->ratio)) return false; return ($this->ratio[$currencyType] * $this->money); //a float number }
Shoe
source share