| 1 | <?php |
| 2 | |
| 3 | namespace Wikimedia\WRStats; |
| 4 | |
| 5 | /** |
| 6 | * A time range |
| 7 | * |
| 8 | * @since 1.39 |
| 9 | */ |
| 10 | class TimeRange { |
| 11 | /** @var float|int UNIX start time */ |
| 12 | public $start; |
| 13 | /** @var float|int UNIX end time */ |
| 14 | public $end; |
| 15 | |
| 16 | /** |
| 17 | * @internal |
| 18 | * |
| 19 | * @param float|int $start |
| 20 | * @param float|int $end |
| 21 | */ |
| 22 | public function __construct( $start, $end ) { |
| 23 | $this->start = $start; |
| 24 | $this->end = $end; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Get the duration of the time range in seconds. |
| 29 | * |
| 30 | * @return float|int |
| 31 | */ |
| 32 | public function getDuration() { |
| 33 | return $this->end - $this->start; |
| 34 | } |
| 35 | } |