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

ExtendableRenderer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 31.25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 18
c 1
b 0
f 0
dl 0
loc 38
ccs 5
cts 16
cp 0.3125
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A render() 0 17 5
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\Renderer\Image\Overlay;
15
16
use Ivory\GoogleMap\Base\Coordinate;
17
use Ivory\GoogleMap\Helper\Renderer\Image\Base\CoordinateRenderer;
18
use Ivory\GoogleMap\Overlay\Marker;
19
use Ivory\GoogleMap\Overlay\Polyline;
20
21
class ExtendableRenderer
22
{
23
    /** @var CoordinateRenderer */
24
    private $coordinateRenderer;
25
26
    /** @var MarkerLocationRenderer */
27
    private $markerLocationRenderer;
28
29
    /** @var PolylineLocationRenderer */
30
    private $polylineLocationRenderer;
31
32 1
    public function __construct(
33
        CoordinateRenderer $coordinateRenderer,
34
        MarkerLocationRenderer $markerLocationRenderer,
35
        PolylineLocationRenderer $polylineLocationRenderer
36
    ) {
37 1
        $this->coordinateRenderer       = $coordinateRenderer;
38 1
        $this->markerLocationRenderer   = $markerLocationRenderer;
39 1
        $this->polylineLocationRenderer = $polylineLocationRenderer;
40 1
    }
41
42
    public function render(array $extendables): string
43
    {
44
        $result = [];
45
46
        foreach ($extendables as $value) {
47
            if ($value instanceof Coordinate) {
48
                $result[] = $this->coordinateRenderer->render($value);
49
            } elseif ($value instanceof Marker) {
50
                $result[] = $this->markerLocationRenderer->render($value);
51
            } elseif ($value instanceof Polyline) {
52
                $result[] = $this->polylineLocationRenderer->render($value);
53
            } else {
54
                $result[] = $value;
55
            }
56
        }
57
58
        return implode('|', $result);
59
    }
60
}
61