ExtendableRenderer::render()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 0
cts 11
cp 0
rs 9.3554
c 0
b 0
f 0
cc 5
nc 5
nop 1
crap 30
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map 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\GoogleMap\Helper\Renderer\Image\Overlay;
13
14
use Ivory\GoogleMap\Base\Coordinate;
15
use Ivory\GoogleMap\Helper\Renderer\Image\Base\CoordinateRenderer;
16
use Ivory\GoogleMap\Overlay\Marker;
17
use Ivory\GoogleMap\Overlay\Polyline;
18
19
/**
20
 * @author GeLo <[email protected]>
21
 */
22
class ExtendableRenderer
23
{
24
    /**
25
     * @var CoordinateRenderer
26
     */
27
    private $coordinateRenderer;
28
29
    /**
30
     * @var MarkerLocationRenderer
31
     */
32
    private $markerLocationRenderer;
33
34
    /**
35
     * @var PolylineLocationRenderer
36
     */
37
    private $polylineLocationRenderer;
38
39 4
    public function __construct(
40
        CoordinateRenderer $coordinateRenderer,
41
        MarkerLocationRenderer $markerLocationRenderer,
42
        PolylineLocationRenderer $polylineLocationRenderer
43
    ) {
44 4
        $this->coordinateRenderer = $coordinateRenderer;
45 4
        $this->markerLocationRenderer = $markerLocationRenderer;
46 4
        $this->polylineLocationRenderer = $polylineLocationRenderer;
47 4
    }
48
49
    /**
50
     * @param mixed[] $extendables
51
     *
52
     * @return string
53
     */
54
    public function render(array $extendables)
55
    {
56
        $result = [];
57
58
        foreach ($extendables as $value) {
59
            if ($value instanceof Coordinate) {
60
                $result[] = $this->coordinateRenderer->render($value);
61
            } elseif ($value instanceof Marker) {
62
                $result[] = $this->markerLocationRenderer->render($value);
63
            } elseif ($value instanceof Polyline) {
64
                $result[] = $this->polylineLocationRenderer->render($value);
65
            } else {
66
                $result[] = $value;
67
            }
68
        }
69
70
        return implode('|', $result);
71
    }
72
}
73