NameTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 7 3
A setName() 0 4 1
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\LeafLet;
11
12
trait NameTrait
13
{
14
    /**
15
     * @var string the variable name. If not null, then the js creation script
16
     * will be returned as a variable. If null, then the js creation script will
17
     * be returned as a constructor that you can use on other object's configuration options.
18
     */
19
    private $_name;
20
21
    /**
22
     * Returns the name of the layer.
23
     *
24
     * @param boolean $autoGenerate whether to generate a name if it is not set previously
25
     *
26
     * @return string name of the layer.
27
     */
28 147
    public function getName($autoGenerate = false)
29
    {
30 147
        if ($autoGenerate && $this->_name === null) {
31 39
            $this->_name = LeafLet::generateName();
32 39
        }
33 147
        return $this->_name;
34
    }
35
36
    /**
37
     * Sets the name of the layer.
38
     *
39
     * @param string $value name of the layer.
40
     */
41 66
    public function setName($value)
42
    {
43 66
        $this->_name = $value;
44 66
    }
45
}
46