MathPHP\Functions\Piecewise::__invoke PHP Метод

__invoke() публичный Метод

When a callback function is being evaluated at a specific point, find the the corresponding function for that point in the domain, and then return the function evaluated at that point. If no function is found, throw an Exception.
public __invoke ( number $x₀ ) : number
$x₀ number The value at which we are evaluating our piecewise function
Результат number The specific function evaluated at $x₀
    public function __invoke($x₀)
    {
        $function = $this->getFunction($x₀);
        if ($function === false) {
            throw new Exception\BadDataException("The input {$x₀} is not in the domain of this piecewise function, thus it is undefined at that point.");
        }
        return $function($x₀);
    }