<?php

/**
 * Beta
 */
class Beta
{
    /**
     * α
     *
     * @var float
     * @access public
     */
    public $α;

    /**
     * β
     *
     * @var float
     * @access public
     */
    public $β;

    public $service;

    public $path;

    /**
     * 构造方法。
     *
     * The construct function.
     *
     * @access public
     * @return void
     */
    public function __construct($α, $β)
    {
        global $config;
        $this->service = $config->gonumService;
        $this->path    = dirname(__DIR__);
        $this->α = $α;
        $this->β = $β;
    }

    public function inverse($p)
    {
        $path   = $this->path;
        $result = exec("$path/{$this->service} -exec -alpha={$this->α} -beta={$this->β} -p=$p");
        return is_numeric($result) ? $result : (float)$result;
    }
}
