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

ZoomSubscriber::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
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\Subscriber\Image;
15
16
use Ivory\GoogleMap\Helper\Event\StaticMapEvent;
17
use Ivory\GoogleMap\Helper\Event\StaticMapEvents;
18
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
19
20
class ZoomSubscriber implements EventSubscriberInterface
21
{
22
    public function handleMap(StaticMapEvent $event): void
23
    {
24
        $map = $event->getMap();
25
26
        if ($map->hasMapOption('zoom')) {
27
            $zoom = $map->getMapOption('zoom');
28
        } elseif (!$map->isAutoZoom()) {
29
            $zoom = 3;
30
        }
31
32
        if (isset($zoom)) {
33
            $event->setParameter('zoom', $zoom);
34
        }
35
    }
36
37
    /** {@inheritdoc} */
38 1
    public static function getSubscribedEvents(): array
39
    {
40 1
        return [StaticMapEvents::ZOOM => 'handleMap'];
41
    }
42
}
43