ImageOverlay   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 48
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setImageBounds() 0 4 1
A getImageBounds() 0 4 1
A encode() 0 14 4
1
<?php
2
/**
3
 * @copyright Copyright (c) 2013-2015 2amigOS! Consulting Group LLC
4
 * @link http://2amigos.us
5
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
6
 */
7
namespace dosamigos\leaflet\layers;
8
9
10
use dosamigos\leaflet\types\LatLngBounds;
11
use yii\web\JsExpression;
12
13
/**
14
 * ImageOverlay it is used to load and display a single image over specific bounds of the map
15
 *
16
 * @see http://leafletjs.com/reference.html#imageoverlay
17
 * @author Antonio Ramirez <[email protected]>
18
 * @link http://www.ramirezcobos.com/
19
 * @link http://www.2amigos.us/
20
 * @package extensions\leafletjs\layers
21
 */
22
/**
23
 * @property string $name
24
 */
25
class ImageOverlay extends Layer
26
{
27
    /**
28
     * @var string the image Url
29
     */
30
    public $imageUrl;
31
32
    /**
33
     * @var LatLngBounds
34
     */
35
    private $_bounds;
36
37
    /**
38
     * @param LatLngBounds $bounds
39
     */
40 9
    public function setImageBounds(LatLngBounds $bounds)
41
    {
42 9
        $this->_bounds = $bounds;
43 9
    }
44
45
    /**
46
     * @return LatLngBounds
47
     */
48 9
    public function getImageBounds()
49
    {
50 9
        return $this->_bounds;
51
    }
52
53
    /**
54
     * Returns the javascript ready code for the object to render
55
     * @return \yii\web\JsExpression
56
     */
57 9
    public function encode()
58
    {
59 9
        $name = $this->name;
60 9
        $imageUrl = $this->imageUrl;
61 9
        $bounds = $this->getImageBounds()->encode();
62 9
        $options = $this->getOptions();
63 9
        $map = $this->map;
64 9
        $js = "L.imageOverlay('$imageUrl', $bounds, $options)" . ($map !== null ? ".addTo($map);" : "");
65 9
        if (!empty($name)) {
66 3
            $js = "var $name = $js" . ($map !== null ? "" : ";");
67 3
        }
68
69 9
        return new JsExpression($js);
70
    }
71
72
}
73