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.

IntegerObject::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LM\Common\Model;
6
7
use Serializable;
8
use UnexpectedValueException;
9
10
/**
11
 * Immutable object that represents an integer.
12
 */
13
class IntegerObject implements Serializable
14
{
15
    /** @var int */
16
    private $integer;
17
18
    /**
19
     * @param int $integer The value to initialise the object with.
20
     */
21
    public function __construct(int $integer)
22
    {
23
        $this->integer = $integer;
24
    }
25
26
    /**
27
     * @return int The integer value of the object.
28
     */
29
    public function toInteger(): int
30
    {
31
        return $this->integer;
32
    }
33
34
    public function serialize(): string
35
    {
36
        return serialize($this->integer);
37
    }
38
39
    public function unserialize($serialized): void
40
    {
41
        $unserialized = unserialize($serialized);
42
        if (is_int($unserialized)) {
43
            $this->integer = $unserialized;
44
        } else {
45
            throw new UnexpectedValueException();
46
        }
47
    }
48
}
49