Token::generatedAt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Project: token-generator
4
 * Created by: ngdo on 01/09/18
5
 */
6
declare(strict_types=1);
7
8
namespace BSP\TokenGenerator;
9
10
use DateInterval;
11
use DateTimeImmutable;
12
13
class Token implements TokenInterface
14
{
15
    private $value;
16
17
    private $generatedAt;
18
19
    private $expireAt;
20
21 6
    public function __construct(string $value, DateInterval $duration)
22
    {
23 6
        $now = new DateTimeImmutable();
24 6
        $expireAt = (new DateTimeImmutable())->add($duration);
25
26 6
        $this->value = $value;
27 6
        $this->generatedAt = $now;
28 6
        $this->expireAt = $expireAt;
29 6
    }
30
31 6
    public function value(): string
32
    {
33 6
        return $this->value;
34
    }
35
36 6
    public function generatedAt(): DateTimeImmutable
37
    {
38 6
        return $this->generatedAt;
39
    }
40
41 6
    public function expireAt(): DateTimeImmutable
42
    {
43 6
        return $this->expireAt;
44
    }
45
}
46