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 — place-services ( 94b48b...a9c14c )
by Eric
67:56 queued 04:38
created

AbstractSerializableService   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 0
loc 84
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getSerializer() 0 4 1
A setSerializer() 0 4 1
A getFormat() 0 4 1
A setFormat() 0 4 1
A deserialize() 0 4 1
A createBaseUrl() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Service;
13
14
use Http\Client\HttpClient;
15
use Http\Message\MessageFactory;
16
use Ivory\GoogleMap\Service\Serializer\SerializerBuilder;
17
use Ivory\Serializer\Context\ContextInterface;
18
use Ivory\Serializer\Format;
19
use Ivory\Serializer\SerializerInterface;
20
use Psr\Http\Message\ResponseInterface;
21
22
/**
23
 * @author GeLo <[email protected]>
24
 */
25
abstract class AbstractSerializableService extends AbstractHttpService
26
{
27
    const FORMAT_JSON = Format::JSON;
28
    const FORMAT_XML = Format::XML;
29
30
    /**
31
     * @var SerializerInterface
32
     */
33
    private $serializer;
34
35
    /**
36
     * @var string
37
     */
38
    private $format = self::FORMAT_JSON;
39
40
    /**
41
     * @param string                   $url
42
     * @param HttpClient               $client
43
     * @param MessageFactory           $messageFactory
44
     * @param SerializerInterface|null $serializer
45
     */
46
    public function __construct(
47
        $url,
48
        HttpClient $client,
49
        MessageFactory $messageFactory,
50
        SerializerInterface $serializer = null
51
    ) {
52
        parent::__construct($url, $client, $messageFactory);
53
54
        $this->setSerializer($serializer ?: SerializerBuilder::create());
55
    }
56
57
    /**
58
     * @return SerializerInterface
59
     */
60
    public function getSerializer()
61
    {
62
        return $this->serializer;
63
    }
64
65
    /**
66
     * @param SerializerInterface $serializer
67
     */
68
    public function setSerializer(SerializerInterface $serializer)
69
    {
70
        $this->serializer = $serializer;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getFormat()
77
    {
78
        return $this->format;
79
    }
80
81
    /**
82
     * @param string $format
83
     */
84
    public function setFormat($format)
85
    {
86
        $this->format = $format;
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92
    protected function createBaseUrl(RequestInterface $request)
93
    {
94
        return parent::createBaseUrl($request).'/'.$this->format;
95
    }
96
97
    /**
98
     * @param ResponseInterface     $response
99
     * @param string                $type
100
     * @param ContextInterface|null $context
101
     *
102
     * @return mixed
103
     */
104
    protected function deserialize(ResponseInterface $response, $type, ContextInterface $context = null)
105
    {
106
        return $this->serializer->deserialize((string) $response->getBody(), $type, $this->format, $context);
107
    }
108
}
109