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 — master ( f9b38c...aac4f4 )
by Márk
10s
created

PlainMessageNormalizer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 45
ccs 10
cts 15
cp 0.6667
rs 10
c 0
b 0
f 0

4 Methods

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