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

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 36
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

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