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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A toInteger() 0 3 1
A serialize() 0 3 1
A unserialize() 0 7 2
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