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

Decimal::original()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
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
    Exception\OutOfRangeValue,
9
};
10
use Innmind\Math\{
11
    Algebra\Number,
12
    Algebra\Integer,
13
    DefinitionSet\Set,
14
    DefinitionSet\NaturalNumbers,
15
};
16
use Innmind\Stream\Readable;
17
18
final class Decimal implements Value
19
{
20
    private static $definitionSet;
21
22
    private $value;
23
    private $original;
24
25 6
    public function __construct(Integer $value, Integer $scale)
26
    {
27 6
        if (!self::definitionSet()->contains($scale)) {
28
            throw new OutOfRangeValue($scale, self::definitionSet());
29
        }
30
31 6
        $this->value = (string) new UnsignedOctet($scale);
32 6
        $this->value .= (string) new SignedLongInteger($value);
33 6
        $this->original = $value->divideBy(
34 6
            (new Integer(10))->power($scale)
35
        );
36 6
    }
37
38 3
    public static function fromStream(Readable $stream): Value
39
    {
40 3
        $scale = UnsignedOctet::fromStream($stream)->original();
41 3
        $value = SignedLongInteger::fromStream($stream)->original();
42
43 3
        return new self($value, $scale);
44
    }
45
46 5
    public function original(): Number
47
    {
48 5
        return $this->original;
49
    }
50
51 5
    public function __toString(): string
52
    {
53 5
        return $this->value;
54
    }
55
56 6
    public static function definitionSet(): Set
57
    {
58 6
        return self::$definitionSet ?? self::$definitionSet = new NaturalNumbers;
59
    }
60
}
61