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 (#177)
by Eric
06:31 queued 03:20
created

AbstractParsableService::createUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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\Utility\JsonParser;
17
use Ivory\GoogleMap\Service\Utility\Parser;
18
use Ivory\GoogleMap\Service\Utility\XmlParser;
19
20
/**
21
 * @author GeLo <[email protected]>
22
 */
23
abstract class AbstractParsableService extends AbstractService
24
{
25
    const FORMAT_JSON = Parser::FORMAT_JSON;
26
    const FORMAT_XML = Parser::FORMAT_XML;
27
28
    /**
29
     * @var Parser
30
     */
31
    private $parser;
32
33
    /**
34
     * @var string
35
     */
36
    private $format = self::FORMAT_JSON;
37
38
    /**
39
     * @param HttpClient     $client
40
     * @param MessageFactory $messageFactory
41
     * @param string         $url
42
     * @param Parser|null    $parser
43
     */
44
    public function __construct(HttpClient $client, MessageFactory $messageFactory, $url, Parser $parser = null)
45
    {
46
        parent::__construct($client, $messageFactory, $url);
47
48
        if ($parser === null) {
49
            $parser = new Parser([
50
                self::FORMAT_JSON => new JsonParser(),
51
                self::FORMAT_XML  => new XmlParser(),
52
            ]);
53
        }
54
55
        $this->setParser($parser);
56
    }
57
58
    /**
59
     * @return Parser
60
     */
61
    public function getParser()
62
    {
63
        return $this->parser;
64
    }
65
66
    /**
67
     * @param Parser $parser
68
     */
69
    public function setParser(Parser $parser)
70
    {
71
        $this->parser = $parser;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getFormat()
78
    {
79
        return $this->format;
80
    }
81
82
    /**
83
     * @param string $format
84
     */
85
    public function setFormat($format)
86
    {
87
        $this->format = $format;
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    protected function createUrl(RequestInterface $request)
94
    {
95
        return parent::createUrl($request).'/'.$this->format;
96
    }
97
98
    /**
99
     * @param string  $data
100
     * @param mixed[] $options
101
     *
102
     * @return mixed[]
103
     */
104
    protected function parse($data, array $options = [])
105
    {
106
        return $this->parser->parse($data, $this->format, $options);
107
    }
108
}
109