Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
SequenceSpec
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Wikimedia\WRStats;
4
5/**
6 * Class representation of normalized sequence specifications.
7 *
8 * @internal
9 */
10class SequenceSpec {
11    /** The default time bucket size (seconds) */
12    public const DEFAULT_TIME_STEP = 600;
13
14    /** The default expiry time (seconds) */
15    public const DEFAULT_EXPIRY = 3600;
16
17    /** @var string */
18    public $name;
19    /** @var float|int */
20    public $timeStep;
21    /** @var float|int */
22    public $softExpiry;
23    /** @var int */
24    public $hardExpiry;
25
26    /**
27     * @param array $spec
28     */
29    public function __construct( array $spec ) {
30        $this->timeStep = $spec['timeStep'] ?? self::DEFAULT_TIME_STEP;
31        $this->softExpiry = $spec['expiry'] ?? self::DEFAULT_EXPIRY;
32        $this->hardExpiry = (int)ceil( $this->softExpiry + $this->timeStep );
33        $this->name = $spec['name'] ?? '';
34    }
35}