GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

MarkerRenderer   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 7
dl 0
loc 79
ccs 35
cts 35
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getAnimationRenderer() 0 4 1
A setAnimationRenderer() 0 4 1
B render() 0 34 6
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\Overlay;
13
14
use Ivory\GoogleMap\Helper\Formatter\Formatter;
15
use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer;
16
use Ivory\GoogleMap\Map;
17
use Ivory\GoogleMap\Overlay\Marker;
18
use Ivory\JsonBuilder\JsonBuilder;
19
20
/**
21
 * @author GeLo <[email protected]>
22
 */
23
class MarkerRenderer extends AbstractJsonRenderer
24
{
25
    /**
26
     * @var AnimationRenderer
27
     */
28
    private $animationRenderer;
29
30
    /**
31
     * @param Formatter         $formatter
32
     * @param JsonBuilder       $jsonBuilder
33
     * @param AnimationRenderer $animationRenderer
34
     */
35 240
    public function __construct(
36
        Formatter $formatter,
37
        JsonBuilder $jsonBuilder,
38
        AnimationRenderer $animationRenderer
39
    ) {
40 240
        parent::__construct($formatter, $jsonBuilder);
41
42 240
        $this->setAnimationRenderer($animationRenderer);
43 240
    }
44
45
    /**
46
     * @return AnimationRenderer
47
     */
48 4
    public function getAnimationRenderer()
49
    {
50 4
        return $this->animationRenderer;
51
    }
52
53
    /**
54
     * @param AnimationRenderer $animationRenderer
55
     */
56 240
    public function setAnimationRenderer(AnimationRenderer $animationRenderer)
57
    {
58 240
        $this->animationRenderer = $animationRenderer;
59 240
    }
60
61
    /**
62
     * @param Marker   $marker
63
     * @param Map|null $map
64
     *
65
     * @return string
66
     */
67 60
    public function render(Marker $marker, Map $map = null)
68
    {
69 60
        $formatter = $this->getFormatter();
70 60
        $jsonBuilder = $this->getJsonBuilder()
71 60
            ->setValue('[position]', $marker->getPosition()->getVariable(), false);
72
73 60
        if ($map !== null) {
74 48
            $jsonBuilder->setValue('[map]', $map->getVariable(), false);
75 24
        }
76
77 60
        if ($marker->hasAnimation()) {
78 12
            $jsonBuilder->setValue(
79 12
                '[animation]',
80 12
                $this->animationRenderer->render($marker->getAnimation()),
81 6
                false
82 6
            );
83 6
        }
84
85 60
        if ($marker->hasIcon()) {
86 12
            $jsonBuilder->setValue('[icon]', $marker->getIcon()->getVariable(), false);
87 54
        } elseif ($marker->hasSymbol()) {
88 8
            $jsonBuilder->setValue('[icon]', $marker->getSymbol()->getVariable(), false);
89 4
        }
90
91 60
        if ($marker->hasShape()) {
92 12
            $jsonBuilder->setValue('[shape]', $marker->getShape()->getVariable(), false);
93 6
        }
94
95 60
        $jsonBuilder->setValues($marker->getOptions());
96
97 60
        return $formatter->renderObjectAssignment($marker, $formatter->renderObject('Marker', [
98 60
            $jsonBuilder->build(),
99 30
        ]));
100
    }
101
}
102