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

ExtendableRenderer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 3
crap 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\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