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

ApiExtension::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 Api 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\ApiHelper;
17
use Twig\Extension\AbstractExtension;
18
use Twig\TwigFunction;
19
20
class ApiExtension extends AbstractExtension
21
{
22
    /** @var ApiHelper */
23
    private $apiHelper;
24
25 1
    public function __construct(ApiHelper $apiHelper)
26
    {
27 1
        $this->apiHelper = $apiHelper;
28 1
    }
29
30
    /** {@inheritdoc} */
31 1
    public function getFunctions(): array
32
    {
33 1
        $functions = [];
34
35 1
        foreach ($this->getMapping() as $name => $method) {
36 1
            $functions[] = new TwigFunction($name, [$this, $method], ['is_safe' => ['html']]);
37
        }
38
39 1
        return $functions;
40
    }
41
42 1
    public function render(array $objects): string
43
    {
44 1
        return $this->apiHelper->render($objects);
45
    }
46
47
    public function getName(): string
48
    {
49
        return 'ivory_google_api';
50
    }
51
52 1
    private function getMapping(): array
53
    {
54 1
        return ['ivory_google_api' => 'render'];
55
    }
56
}
57