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 ( f63f76...166806 )
by Romain
01:46
created

HalapiBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A getSerializer() 0 11 1
1
<?php
2
3
namespace Halapi;
4
5
use Halapi\Factory\RelationFactory;
6
use Halapi\Subscriber\JsonEventSubscriber;
7
use JMS\Serializer\EventDispatcher\EventDispatcherInterface;
8
use JMS\Serializer\SerializerBuilder;
9
10
/**
11
 * Class HalapiBuilder.
12
 *
13
 * @author Romain Richard
14
 */
15
class HalapiBuilder
16
{
17
    /**
18
     * @var RelationFactory
19
     */
20
    private $relationFactory;
21
22
    /**
23
     * @var SerializerBuilder
24
     */
25
    private $serializerBuilder;
26
27
    /**
28
     * HALAPIBuilder constructor.
29
     *
30
     * @param RelationFactory        $relationFactory
31
     * @param SerializerBuilder|null $serializerBuilder
32
     */
33
    public function __construct(
34
        RelationFactory $relationFactory,
35
        SerializerBuilder $serializerBuilder = null
36
    ) {
37
        $this->relationFactory = $relationFactory;
38
        $this->serializerBuilder = $serializerBuilder ?: SerializerBuilder::create();
39
    }
40
41
    /**
42
     * @return \JMS\Serializer\Serializer
43
     */
44
    public function getSerializer()
45
    {
46
        $this->serializerBuilder
47
            ->addDefaultListeners()
48
            ->configureListeners(function (EventDispatcherInterface $dispatcher) {
49
                $dispatcher->addSubscriber(new JsonEventSubscriber($this->relationFactory));
50
            })
51
        ;
52
53
        return $this->serializerBuilder->build();
54
    }
55
}
56