StaticMapExtension::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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\StaticMapHelper;
15
use Ivory\GoogleMap\Map;
16
17
/**
18
 * @author GeLo <[email protected]>
19
 */
20 View Code Duplication
class StaticMapExtension extends \Twig_Extension
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * @var StaticMapHelper
24
     */
25
    private $staticMapHelper;
26
27
    /**
28
     * @param StaticMapHelper $staticMapHelper
29
     */
30 1
    public function __construct(StaticMapHelper $staticMapHelper)
31
    {
32 1
        $this->staticMapHelper = $staticMapHelper;
33 1
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 1
    public function getFunctions()
39
    {
40 1
        $functions = [];
41
42 1
        foreach ($this->getMapping() as $name => $method) {
43 1
            $functions[] = new \Twig_SimpleFunction($name, [$this, $method], ['is_safe' => ['html']]);
44
        }
45
46 1
        return $functions;
47
    }
48
49
    /**
50
     * @param Map $map
51
     *
52
     * @return string
53
     */
54 1
    public function render(Map $map)
55
    {
56 1
        return $this->staticMapHelper->render($map);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 1
    public function getName()
63
    {
64 1
        return 'ivory_google_map_static';
65
    }
66
67
    /**
68
     * @return string[]
69
     */
70 1
    private function getMapping()
71
    {
72 1
        return ['ivory_google_map_static' => 'render'];
73
    }
74
}
75