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.
Completed
Pull Request — master (#1)
by Pascal
03:33
created

AbstractSerializer::deserialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Saikootau\ApiBundle\Serializer;
6
7
use JMS\Serializer\Serializer as JMSSerializer;
8
9
abstract class AbstractSerializer implements Serializer
10
{
11
    private $serializer;
12
13 7
    public function __construct(JMSSerializer $serializer)
14
    {
15 7
        $this->serializer = $serializer;
16 7
    }
17
18
    /**
19
     * Serialize the document to a format.
20
     *
21
     * @param object $document
22
     *
23
     * @return string
24
     */
25 2
    public function serialize(object $document): string
26
    {
27 2
        return $this->serializer->serialize(
28 2
            $document,
29 2
            $this->getSupportedFormat()
30
        );
31
    }
32
33
    /**
34
     * Deserialize the document to a PHP object of the given class.
35
     *
36
     * @param string $document
37
     * @param string $className
38
     *
39
     * @return object
40
     */
41 3
    public function deserialize(string $document, string $className): object
42
    {
43 3
        return $this->serializer->deserialize(
44 3
            $document,
45 3
            $className,
46 3
            $this->getSupportedFormat()
47
        );
48
    }
49
50
    /**
51
     * Return the supported format by the serializer.
52
     *
53
     * @return string
54
     */
55
    abstract public function getSupportedFormat(): string;
56
}
57