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.

Serializer::createAggregateNormalizer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Bernard;
4
5
use Normalt\Normalizer\AggregateNormalizer;
6
7
class Serializer
8
{
9
    protected $aggregate;
10
11
    /**
12
     * @param AggregateNormalizer|null $aggregate
13
     */
14 2
    public function __construct(AggregateNormalizer $aggregate = null)
15
    {
16 2
        $this->aggregate = $aggregate ?: $this->createAggregateNormalizer();
17 2
    }
18
19
    /**
20
     * @param Envelope $envelope
21
     *
22
     * @return string
23
     */
24 1
    public function serialize(Envelope $envelope)
25
    {
26 1
        return json_encode($this->aggregate->normalize($envelope));
27
    }
28
29
    /**
30
     * @param string $contents
31
     *
32
     * @return Envelope
33
     */
34 1
    public function unserialize($contents)
35
    {
36 1
        $data = json_decode($contents, true);
37
38 1
        return $this->aggregate->denormalize($data, 'Bernard\Envelope');
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->aggregate->denorm..., 'Bernard\\Envelope'); of type object|array adds the type array to the return on line 38 which is incompatible with the return type documented by Bernard\Serializer::unserialize of type Bernard\Envelope.
Loading history...
39
    }
40
41
    /**
42
     * @return AggregateNormalizer
43
     */
44
    private function createAggregateNormalizer()
45
    {
46
        return new AggregateNormalizer([
47
            new Normalizer\EnvelopeNormalizer(),
48
            new Normalizer\PlainMessageNormalizer(),
49
        ]);
50
    }
51
}
52