getTicks() public method

Get the number of ticks represented by this rate.
public getTicks ( ) : float
return float
示例#1
0
 function it_increments_the_number_of_ticks(RateMeasureStorage $storage, RateMeasure $measure, Rate $rate)
 {
     $rate->getTicks()->willReturn(1);
     $measure->getTime()->willReturn(new \DateTime());
     $measure->getRate()->willReturn($rate);
     $storage->find('id')->willReturn($measure);
     $storage->save('id', Argument::type(RateMeasure::class))->shouldBeCalled();
     $this->tick('id');
 }
示例#2
0
 /**
  * Create the current rate.
  *
  * @param string $identifier
  *
  * @return float
  */
 private function computeCurrentRate($identifier)
 {
     $measure = $this->getMeasure($identifier);
     $lastRequest = (double) $measure->getTime()->format('U.u');
     $lastRatio = $measure->getRate()->getTicks();
     $difference = (microtime(true) - $lastRequest) * 1000;
     $rate = max(0, $lastRatio - $difference);
     $rate += 1000 / $this->rate->getTicks();
     return $rate;
 }