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
Push — message_refactor ( d8d543 )
by Márk
05:37
created

PlainMessageNormalizer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 40.91%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 41
ccs 9
cts 22
cp 0.4091
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A denormalize() 0 8 1
A supportsDenormalization() 0 4 1
A supportsNormalization() 0 4 1
A normalize() 0 7 1
1
<?php
2
3
namespace Bernard\Normalizer;
4
5
use Assert\Assertion;
6
use Bernard\Message\PlainMessage;
7
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
8
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
9
10
final class PlainMessageNormalizer implements NormalizerInterface, DenormalizerInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 1
    public function normalize($object, $format = null, array $context = [])
16
    {
17
        return [
18 1
            'name' => $object->getName(),
19 1
            'arguments' => $object->all(),
20 1
        ];
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function denormalize($data, $class, $format = null, array $context = [])
27
    {
28 1
        Assertion::notEmptyKey($data, 'name');
29 1
        Assertion::keyExists($data, 'arguments');
30 1
        Assertion::isArray($data['arguments']);
31
32 1
        return new PlainMessage($data['name'], $data['arguments']);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function supportsDenormalization($data, $type, $format = null)
39
    {
40
        return $type === PlainMessage::class;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function supportsNormalization($data, $format = null)
47
    {
48
        return $data instanceof PlainMessage;
49
    }
50
}
51