ServiceBing   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 35
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 2
A registerAssetBundle() 0 4 1
A getJs() 0 4 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2013-2019 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\plugins\geocoder;
8
9
use yii\base\InvalidConfigException;
10
use yii\web\JsExpression;
11
12
/**
13
 * ServiceBing provides the required code and js files to use Bing geocoding service
14
 *
15
 * @author Antonio Ramirez <[email protected]>
16
 * @link http://www.ramirezcobos.com/
17
 * @link http://www.2amigos.us/
18
 * @package dosamigos\leaflet\plugins\geocoder
19
 */
20
class ServiceBing extends BaseService
21
{
22
    /**
23
     * @var string the Bing's API key
24
     */
25
    public $key;
26
27
    /**
28
     * @throws \yii\base\InvalidConfigException
29
     */
30 3
    public function init()
31
    {
32 3
        if($this->key === null) {
33 3
            throw new InvalidConfigException('"$key" cannot be empty.');
34
        }
35 3
    }
36
37
    /**
38
     * @inheritdoc
39
     * @codeCoverageIgnore
40
     */
41
    public function registerAssetBundle($view)
42
    {
43
        ServiceBingAsset::register($view);
44
    }
45
46
    /**
47
     * @return \yii\web\JsExpression the javascript code for the geocoder option to be set
48
     */
49 3
    public function getJs()
50
    {
51 3
        return new JsExpression("L.Control.Geocoder.bing('{$this->key}')");
52
    }
53
54
}
55