Token   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 33
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A value() 0 4 1
A generatedAt() 0 4 1
A expireAt() 0 4 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