PopupTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A bindPopupContent() 0 11 3
1
<?php
2
/**
3
 *
4
 * PopupTrait.php
5
 *
6
 * Date: 15/02/14
7
 * Time: 11:03
8
 * @author Antonio Ramirez <[email protected]>
9
 * @link http://www.ramirezcobos.com/
10
 * @link http://www.2amigos.us/
11
 */
12
13
namespace dosamigos\leaflet\layers;
14
15
16
trait PopupTrait
17
{
18
    /**
19
     * @var string the HTML content of the popup to display when clicking on the marker.
20
     */
21
    public $popupContent;
22
    /**
23
     * @var bool whether to open the popup dialog on display.
24
     */
25
    public $openPopup = false;
26
27
    /**
28
     * Binds popup content (if any) to the js code to register
29
     *
30
     * @param string $js
31
     *
32
     * @return string
33
     */
34 108
    protected function bindPopupContent($js)
35
    {
36 108
        if (!empty($this->popupContent)) {
37 21
            $content = addslashes($this->popupContent);
38 21
            $js .= ".bindPopup(\"{$content}\")";
39 21
            if ($this->openPopup) {
40 3
                $js .= ".openPopup()";
41 3
            }
42 21
        }
43 108
        return $js;
44
    }
45
}
46