MediaWiki REL1_39
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( __METHOD__ .
25 ': window must be positive' );
26 }
27 }
28
34 public function perSecond() {
35 return $this->limit / $this->window;
36 }
37}
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.