TimeToFirstByte::ensureInMilliseconds()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
dl 5
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace DjThossi\SmokeTestingPhp\ValueObject;
3
4
use DjThossi\Ensure\EnsureIsGreaterThanTrait;
5
use DjThossi\Ensure\EnsureIsIntegerTrait;
6
7 View Code Duplication
class TimeToFirstByte
8
{
9
    use EnsureIsIntegerTrait;
10
    use EnsureIsGreaterThanTrait;
11
12
    const IN_MILLISECONDS_IS_NOT_AN_INTEGER = 1;
13
    const IN_MILLISECONDS_IS_TOO_SMALL = 2;
14
15
    /**
16
     * @var int
17
     */
18
    private $inMilliseconds;
19
20
    /**
21
     * @param int $inMilliseconds
22
     */
23
    public function __construct($inMilliseconds)
24
    {
25
        $this->ensureInMilliseconds($inMilliseconds);
26
27
        $this->inMilliseconds = $inMilliseconds;
28
    }
29
30
    /**
31
     * @return int
32
     */
33
    public function inMilliSeconds()
34
    {
35
        return $this->inMilliseconds;
36
    }
37
38
    /**
39
     * @param mixed $inMilliseconds
40
     */
41
    private function ensureInMilliseconds($inMilliseconds)
42
    {
43
        $this->ensureIsInteger('InMilliseconds', $inMilliseconds, self::IN_MILLISECONDS_IS_NOT_AN_INTEGER);
44
        $this->ensureIsGreaterThan('InMilliseconds', 0, $inMilliseconds, self::IN_MILLISECONDS_IS_TOO_SMALL);
45
    }
46
}
47