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
Pull Request — master (#556)
by Evgenij
02:42
created

createDeserializationContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace JMS\SerializerBundle\ContextFactory;
4
5
use JMS\Serializer\Context;
6
use JMS\Serializer\ContextFactory\DeserializationContextFactoryInterface;
7
use JMS\Serializer\ContextFactory\SerializationContextFactoryInterface;
8
use JMS\Serializer\DeserializationContext;
9
use JMS\Serializer\SerializationContext;
10
11
/**
12
 * Class ConfiguredContextFactory
13
 */
14
class ConfiguredContextFactory implements SerializationContextFactoryInterface, DeserializationContextFactoryInterface
15
{
16
    /**
17
     * Context config
18
     *
19
     * @var array
20
     */
21
    private $config;
22
23
    /**
24
     * ConfiguredContextFactory constructor.
25
     *
26
     * @param array $config Context configuration
27
     */
28
    public function __construct(array $config)
29
    {
30
        $this->config = $config;
31
    }
32
33
    /**
34
     * @inheritDoc
35
     */
36
    public function createDeserializationContext()
37
    {
38
        return $this->configureContext(new DeserializationContext());
39
    }
40
41
    /**
42
     * @inheritDoc
43
     */
44
    public function createSerializationContext()
45
    {
46
        return $this->configureContext(new SerializationContext());
47
    }
48
49
    /**
50
     * Configures context according to configuration
51
     *
52
     * @param Context $context The context
53
     *
54
     * @return Context Given object
55
     */
56
    private function configureContext(Context $context)
57
    {
58
        foreach ($this->config['attributes'] as $key => $value) {
59
            $context->setAttribute($key, $value);
60
        }
61
62
        $context->setGroups($this->config['groups']);
63
        $context->setSerializeNull($this->config['serialize_null']);
64
        if ($this->config['version'] !== null) {
65
            $context->setVersion($this->config['version']);
66
        }
67
68
        return $context;
69
    }
70
}
71