NameTrait::setName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 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