PlaceAutocompleteHelper::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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;
13
14
use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvent;
15
use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvents;
16
use Ivory\GoogleMap\Place\Autocomplete;
17
18
/**
19
 * @author GeLo <[email protected]>
20
 */
21
class PlaceAutocompleteHelper extends AbstractHelper
22
{
23
    /**
24
     * @return string
25
     */
26
    public function render(Autocomplete $autocomplete)
27
    {
28
        return $this->renderHtml($autocomplete).$this->renderJavascript($autocomplete);
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function renderHtml(Autocomplete $autocomplete)
35
    {
36
        return $this->doRender($autocomplete, PlaceAutocompleteEvents::HTML);
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function renderJavascript(Autocomplete $autocomplete)
43
    {
44
        return $this->doRender($autocomplete, PlaceAutocompleteEvents::JAVASCRIPT);
45
    }
46
47
    /**
48
     * @param string $eventName
49
     *
50
     * @return string
51
     */
52
    private function doRender(Autocomplete $autocomplete, $eventName)
53
    {
54
        $this->getEventDispatcher()->dispatch($event = new PlaceAutocompleteEvent($autocomplete), $eventName);
0 ignored issues
show
Documentation introduced by
$event = new \Ivory\Goog...eteEvent($autocomplete) is of type object<Ivory\GoogleMap\H...PlaceAutocompleteEvent>, but the function expects a object<Symfony\Contracts\EventDispatcher\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
55
56
        return $event->getCode();
57
    }
58
}
59