Passed
Push — feature/v4 ( 2fc063...abe85a )
by Samuel
05:52
created

StaticMapExtension::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Ivory Google Map bundle package.
7
 *
8
 * (c) Eric GELOEN <[email protected]>
9
 *
10
 * For the full copyright and license information, please read the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ivory\GoogleMapBundle\Twig;
15
16
use Ivory\GoogleMap\Helper\StaticMapHelper;
17
use Ivory\GoogleMap\Map;
18
use Twig\Extension\AbstractExtension;
19
use Twig\TwigFunction;
20
21
class StaticMapExtension extends AbstractExtension
22
{
23
    /** @var StaticMapHelper */
24
    private $staticMapHelper;
25
26 1
    public function __construct(StaticMapHelper $staticMapHelper)
27
    {
28 1
        $this->staticMapHelper = $staticMapHelper;
29 1
    }
30
31
    /** {@inheritdoc} */
32 1
    public function getFunctions(): array
33
    {
34 1
        $functions = [];
35
36 1
        foreach ($this->getMapping() as $name => $method) {
37 1
            $functions[] = new TwigFunction($name, [$this, $method], ['is_safe' => ['html']]);
38
        }
39
40 1
        return $functions;
41
    }
42
43 1
    public function render(Map $map): string
44
    {
45 1
        return $this->staticMapHelper->render($map);
46
    }
47
48
    public function getName(): string
49
    {
50
        return 'ivory_google_map_static';
51
    }
52
53 1
    private function getMapping(): array
54
    {
55 1
        return ['ivory_google_map_static' => 'render'];
56
    }
57
}
58