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.
Completed
Push — develop ( 081f57...404db9 )
by Baptiste
12s queued 11s
created

Timestamp::fromStream()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 1
rs 10
c 0
b 0
f 0
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->original = $point;
26 7
    }
27
28 4
    public static function fromStream(Readable $stream): Value
29
    {
30 4
        $time = UnsignedLongLongInteger::fromStream($stream)
31 4
            ->original()
32 4
            ->value();
33
34 4
        return new self(new PointInTime(
35 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

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