Token::created()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php declare(strict_types = 1);
2
3
namespace Link0\Bunq\Domain;
4
5
use DateTimeImmutable;
6
use DateTimeInterface;
7
use DateTimeZone;
8
9 View Code Duplication
final class Token
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @var Id
13
     */
14
    private $id;
15
16
    /**
17
     * @var DateTimeInterface
18
     */
19
    private $created;
20
21
    /**
22
     * @var DateTimeInterface
23
     */
24
    private $updated;
25
26
    /**
27
     * @var string
28
     */
29
    private $token;
30
31
    /**
32
     * @param array $token
33
     * @return Token
34
     */
35
    public static function fromArray(array $token)
36
    {
37
        $timezone = new DateTimeZone('UTC');
38
        $t = new Token();
39
        $t->id = Id::fromInteger(intval($token['id']));
40
        $t->created = new DateTimeImmutable($token['created'], $timezone);
41
        $t->updated = new DateTimeImmutable($token['updated'], $timezone);
42
        $t->token = $token['token'];
43
        return $t;
44
    }
45
46
    /**
47
     * @return Id
48
     */
49
    public function id(): Id
50
    {
51
        return $this->id;
52
    }
53
54
    /**
55
     * @return DateTimeInterface
56
     */
57
    public function created(): DateTimeInterface
58
    {
59
        return $this->created;
60
    }
61
62
    /**
63
     * @return DateTimeInterface
64
     */
65
    public function updated(): DateTimeInterface
66
    {
67
        return $this->updated;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function token(): string
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
74
    {
75
        return $this->token;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function __toString()
82
    {
83
        return $this->token();
84
    }
85
}
86