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

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 61.53%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 45
ccs 8
cts 13
cp 0.6153
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A serialize() 0 4 1
A unserialize() 0 6 1
A createAggregateNormalizer() 0 7 1
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