GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — develop (#1)
by Baptiste
01:41
created

Timestamp   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 32
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A original() 0 3 1
A fromStream() 0 8 1
A __toString() 0 3 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Frame\Value;
5
6
use Innmind\AMQP\{
7
    Transport\Frame\Value,
8
    TimeContinuum\Format\Timestamp as TimestampFormat,
9
};
10
use Innmind\TimeContinuum\{
11
    PointInTimeInterface,
12
    PointInTime\Earth\PointInTime,
13
    Format\ISO8601,
14
};
15
use Innmind\Math\Algebra\Integer;
16
use Innmind\Stream\Readable;
17
18
final class Timestamp implements Value
19
{
20
    private $value;
21
    private $original;
22
23 7
    public function __construct(PointInTimeInterface $point)
24
    {
25 7
        $this->value = (string) new UnsignedLongLongInteger(
26 7
            new Integer((int) $point->format(new TimestampFormat))
27
        );
28 7
        $this->original = $point;
29 7
    }
30
31 4
    public static function fromStream(Readable $stream): Value
32
    {
33 4
        $time = UnsignedLongLongInteger::fromStream($stream)
34 4
            ->original()
35 4
            ->value();
36
37 4
        return new self(new PointInTime(
38 4
            \date((string) new ISO8601, $time)
0 ignored issues
show
Bug introduced by
It seems like $time can also be of type double; however, parameter $timestamp of date() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
            \date((string) new ISO8601, /** @scrutinizer ignore-type */ $time)
Loading history...
39
        ));
40
    }
41
42 5
    public function original(): PointInTimeInterface
43
    {
44 5
        return $this->original;
45
    }
46
47 6
    public function __toString(): string
48
    {
49 6
        return $this->value;
50
    }
51
}
52