bandwidthThrottle\tokenBucket\Rate::__construct PHP Метод

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

E.g. new Rate(100, Rate::SECOND) will produce 100 tokens per second.
public __construct ( integer $tokens, string $unit )
$tokens integer positive amount of tokens to produce per unit
$unit string unit as one of Rate's constants
    public function __construct($tokens, $unit)
    {
        if (!isset(self::$unitMap[$unit])) {
            throw new \InvalidArgumentException("Not a valid unit.");
        }
        if ($tokens <= 0) {
            throw new \InvalidArgumentException("Amount of tokens should be greater then 0.");
        }
        $this->tokens = $tokens;
        $this->unit = $unit;
    }