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.

PersistOperation::unserialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LM\AuthAbstractor\Model;
6
7
use LM\AuthAbstractor\Enum\Persistence\Operation;
8
9
use Serializable;
10
11
/**
12
 * PersistOperation objects represent actions that need to be persisted by the
13
 * application in some ways (e.g. in a database) when the authentication process
14
 * finishes (i.e. succeeds or fails).
15
 *
16
 * @todo Use an interface?
17
 */
18
class PersistOperation implements Serializable
19
{
20
    /** @var Serializable */
21
    private $object;
22
23
    /** @var Operation */
24
    private $operation;
25
26
    /**
27
     * @param Serializable $object The entity that needs to be persisted.
28
     * @param Operation $operation The type of persistence (update, delete, or
29
     * create).
30
     */
31
    public function __construct(Serializable $object, Operation $operation)
32
    {
33
        $this->object = $object;
34
        $this->operation = $operation;
35
    }
36
37
    /**
38
     * @api
39
     * @return Operation The type of persistence.
40
     */
41
    public function getType(): Operation
42
    {
43
        return $this->operation;
44
    }
45
46
    /**
47
     * @api
48
     * @return Serializable The entity to persist.
49
     */
50
    public function getObject(): Serializable
51
    {
52
        return $this->object;
53
    }
54
55
    public function serialize()
56
    {
57
        return serialize([
58
            $this->object,
59
            $this->operation,
60
        ]);
61
    }
62
63
    public function unserialize($serialized)
64
    {
65
        list(
66
            $this->object,
67
            $this->operation) = unserialize($serialized);
68
    }
69
}
70