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 — language ( 22f462 )
by Eric
02:22
created

LoaderRenderer::render()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

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