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::supportsDenormalization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
crap 2
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