ExtendableRenderer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 31.25%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 51
ccs 5
cts 16
cp 0.3125
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A render() 0 18 5
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