Passed
Push — feature/v4 ( e5e380...dac4aa )
by Samuel
11:37
created

MapHelper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
eloc 7
c 0
b 0
f 0
dl 0
loc 27
ccs 0
cts 11
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A doRender() 0 5 1
A render() 0 3 1
A renderHtml() 0 3 1
A renderStylesheet() 0 3 1
A renderJavascript() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Ivory Google Map 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\GoogleMap\Helper;
15
16
use Ivory\GoogleMap\Helper\Event\MapEvent;
17
use Ivory\GoogleMap\Helper\Event\MapEvents;
18
use Ivory\GoogleMap\Map;
19
20
class MapHelper extends AbstractHelper
21
{
22
    public function render(Map $map): string
23
    {
24
        return $this->renderHtml($map).$this->renderStylesheet($map).$this->renderJavascript($map);
25
    }
26
27
    public function renderHtml(Map $map): string
28
    {
29
        return $this->doRender($map, MapEvents::HTML);
30
    }
31
32
    public function renderStylesheet(Map $map): string
33
    {
34
        return $this->doRender($map, MapEvents::STYLESHEET);
35
    }
36
37
    public function renderJavascript(Map $map): string
38
    {
39
        return $this->doRender($map, MapEvents::JAVASCRIPT);
40
    }
41
42
    private function doRender(Map $map, string $eventName): string
43
    {
44
        $this->getEventDispatcher()->dispatch($event = new MapEvent($map), $eventName);
45
46
        return $event->getCode();
47
    }
48
}
49