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.

StringObject::serialize()   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 0
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 a string.
12
 */
13
class StringObject implements Serializable
14
{
15
    /** @var string */
16
    private $string;
17
18
    /**
19
     * @param string $string The value to initialise the object with.
20
     */
21
    public function __construct(string $string)
22
    {
23
        $this->string = $string;
24
    }
25
26
    /**
27
     * @return string A string representation of the object.
28
     */
29
    public function toString(): string
30
    {
31
        return $this->string;
32
    }
33
34
    /**
35
     * @deprecated
36
     */
37
    public function serialize(): string
38
    {
39
        return serialize($this->string);
40
    }
41
42
    public function unserialize($serialized): void
43
    {
44
        $unserialized = unserialize($serialized);
45
        if (is_string($unserialized)) {
46
            $this->string = $unserialized;
47
        } else {
48
            throw new UnexpectedValueException();
49
        }
50
    }
51
}
52