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 (#135)
by Eric
05:17 queued 02:21
created

LoaderRenderer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 3
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\Helper\Renderer;
13
14
use Ivory\GoogleMap\Helper\Formatter\Formatter;
15
use Ivory\JsonBuilder\JsonBuilder;
16
17
/**
18
 * @author GeLo <[email protected]>
19
 */
20
class LoaderRenderer extends AbstractJsonRenderer
21
{
22
    /**
23
     * @var string
24
     */
25
    private $language;
26
27
    /**
28
     * @param Formatter   $formatter
29
     * @param JsonBuilder $jsonBuilder
30
     * @param string      $language
31
     */
32
    public function __construct(Formatter $formatter, JsonBuilder $jsonBuilder, $language = 'en')
33
    {
34
        parent::__construct($formatter, $jsonBuilder);
35
36
        $this->setLanguage($language);
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getLanguage()
43
    {
44
        return $this->language;
45
    }
46
47
    /**
48
     * @param string $language
49
     */
50
    public function setLanguage($language)
51
    {
52
        $this->language = $language;
53
    }
54
55
    /**
56
     * @param string   $name
57
     * @param string   $callback
58
     * @param string[] $libraries
59
     * @param bool     $newLine
60
     *
61
     * @return string
62
     */
63
    public function render(
64
        $name,
65
        $callback,
66
        array $libraries = [],
67
        $newLine = true
68
    ) {
69
        $formatter = $this->getFormatter();
70
        $jsonBuilder = $this->getJsonBuilder();
71
72
        $parameters = ['language' => $this->language];
73
        if (!empty($libraries)) {
74
            $parameters['libraries'] = implode(',', $libraries);
75
        }
76
77
        $jsonBuilder
78
            ->setValue('[other_params]', urldecode(http_build_query($parameters, '', '&')))
79
            ->setValue('[callback]', $callback, false);
80
81
        return $formatter->renderClosure($formatter->renderCall($formatter->renderProperty('google', 'load'), [
82
            $formatter->renderEscape('maps'),
83
            $formatter->renderEscape('3'),
84
            $jsonBuilder->build(),
85
        ]), [], $name, true, $newLine);
86
    }
87
88
    /**
89
     * @param string $callback
90
     *
91
     * @return string
92
     */
93
    public function renderSource($callback)
94
    {
95
        return 'https://www.google.com/jsapi?callback='.$callback;
96
    }
97
}
98