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.

PlaceAutocompleteExtension   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 0
loc 85
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A render() 0 6 1
A renderHtml() 0 6 1
A renderJavascript() 0 4 1
A getName() 0 4 1
A getMapping() 0 8 1
A getFunctions() 0 10 2
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map bundle 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\GoogleMapBundle\Twig;
13
14
use Ivory\GoogleMap\Helper\PlaceAutocompleteHelper;
15
use Ivory\GoogleMap\Place\Autocomplete;
16
17
/**
18
 * @author GeLo <[email protected]>
19
 */
20
class PlaceAutocompleteExtension extends \Twig_Extension
21
{
22
    /**
23
     * @var PlaceAutocompleteHelper
24
     */
25
    private $placeAutocompleteHelper;
26
27
    /**
28
     * @param PlaceAutocompleteHelper $placeAutocompleteHelper
29
     */
30 27
    public function __construct(PlaceAutocompleteHelper $placeAutocompleteHelper)
31
    {
32 27
        $this->placeAutocompleteHelper = $placeAutocompleteHelper;
33 27
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 27
    public function getFunctions()
39
    {
40 27
        $functions = [];
41
42 27
        foreach ($this->getMapping() as $name => $method) {
43 27
            $functions[] = new \Twig_SimpleFunction($name, [$this, $method], ['is_safe' => ['html']]);
44 21
        }
45
46 27
        return $functions;
47
    }
48
49
    /**
50
     * @param Autocomplete $autocomplete
51
     * @param string[]     $attributes
52
     *
53
     * @return string
54
     */
55 9
    public function render(Autocomplete $autocomplete, array $attributes = [])
56
    {
57 9
        $autocomplete->addInputAttributes($attributes);
58
59 9
        return $this->placeAutocompleteHelper->render($autocomplete);
60
    }
61
62
    /**
63
     * @param Autocomplete $autocomplete
64
     * @param string[]     $attributes
65
     *
66
     * @return string
67
     */
68 9
    public function renderHtml(Autocomplete $autocomplete, array $attributes = [])
69
    {
70 9
        $autocomplete->addInputAttributes($attributes);
71
72 9
        return $this->placeAutocompleteHelper->renderHtml($autocomplete);
73
    }
74
75
    /**
76
     * @param Autocomplete $autocomplete
77
     *
78
     * @return string
79
     */
80 9
    public function renderJavascript(Autocomplete $autocomplete)
81
    {
82 9
        return $this->placeAutocompleteHelper->renderJavascript($autocomplete);
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88 27
    public function getName()
89
    {
90 27
        return 'ivory_google_place_autocomplete';
91
    }
92
93
    /**
94
     * @return string[]
95
     */
96 27
    private function getMapping()
97
    {
98
        return [
99 27
            'ivory_google_place_autocomplete'           => 'render',
100 21
            'ivory_google_place_autocomplete_container' => 'renderHtml',
101 21
            'ivory_google_place_autocomplete_js'        => 'renderJavascript',
102 21
        ];
103
    }
104
}
105