MediaWiki master
LimitCondition.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\WRStats;
4
11 public $limit;
13 public $window;
14
20 public function __construct( $limit, $window ) {
21 $this->limit = (int)$limit;
22 $this->window = +$window;
23 if ( $this->window <= 0 ) {
24 throw new WRStatsError( 'Condition window must be positive' );
25 }
26 }
27
33 public function perSecond() {
34 return $this->limit / $this->window;
35 }
36}
float int $window
The number of seconds over which the number of events may occur.
int $limit
The maximum number of events.
perSecond()
Get the condition as a number of events per second.
Exception class for errors thrown by the WRStats library.